3162. Find the Number of Good Pairs I Easy
1/**
2 * [3162] Find the Number of Good Pairs I
3 *
4 * You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k.
5 * A pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1).
6 * Return the total number of good pairs.
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">nums1 = [1,3,4], nums2 = [1,3,4], k = 1</span>
11 * Output: <span class="example-io">5</span>
12 * Explanation:
13 * The 5 good pairs are (0, 0), (1, 0), (1, 1), (2, 0), and (2, 2).</div>
14 * <strong class="example">Example 2:
15 * <div class="example-block">
16 * Input: <span class="example-io">nums1 = [1,2,4,12], nums2 = [2,4], k = 3</span>
17 * Output: <span class="example-io">2</span>
18 * Explanation:
19 * The 2 good pairs are (3, 0) and (3, 1).
20 * </div>
21 *
22 * Constraints:
23 *
24 * 1 <= n, m <= 50
25 * 1 <= nums1[i], nums2[j] <= 50
26 * 1 <= k <= 50
27 *
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/find-the-number-of-good-pairs-i/
32// discuss: https://leetcode.com/problems/find-the-number-of-good-pairs-i/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37 pub fn number_of_pairs(nums1: Vec<i32>, nums2: Vec<i32>, k: i32) -> i32 {
38 0
39 }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_3162() {
50 }
51}
52
Back
© 2025 bowen.ge All Rights Reserved.