Intersection of Multiple Arrays LeetCode solution in Java

1
class Solution {
2
public List<Integer> intersection(int[][] nums) {
3

4
List<Integer> ans = new ArrayList<>();
5

6
int[] count = new int[1001];
7

8
for (int[] arr : nums) {
9
for (int i : arr) {
10
count[i]++;
11
}
12
}
13

14
for (int i = 0; i < count.length; i++) {
15
if (count[i] == nums.length) {
16
ans.add(i);
17
}
18
}
19

20
return ans;
21
}
22
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0