We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 88ed746 commit 3353523Copy full SHA for 3353523
src/main/java/com/fishercoder/solutions/_3164.java
@@ -0,0 +1,31 @@
1
+package com.fishercoder.solutions;
2
+
3
+import java.util.HashMap;
4
+import java.util.Map;
5
6
+public class _3164 {
7
+ public static class Solution1 {
8
+ public long numberOfPairs(int[] nums1, int[] nums2, int k) {
9
+ long count = 0;
10
+ Map<Integer, Integer> map = new HashMap<>();
11
+ for (int num : nums2) {
12
+ int product = num * k;
13
+ map.put(product, map.getOrDefault(product, 0) + 1);
14
+ }
15
+ for (int num : nums1) {
16
+ for (int j = 1; j * j <= num; j++) {
17
+ if (num % j == 0) {
18
+ if (map.containsKey(j)) {
19
+ count += map.get(j);
20
21
+ int division = num / j;
22
+ if (j != division && map.containsKey(division)) {
23
+ count += map.get(division);
24
25
26
27
28
+ return count;
29
30
31
+}
0 commit comments