-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtech-intervie-workshop-code
More file actions
33 lines (27 loc) · 1013 Bytes
/
tech-intervie-workshop-code
File metadata and controls
33 lines (27 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Solution {
public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {
HashMap<Integer, Boolean> found1 = new HashMap<>();
HashMap<Integer, Boolean> found2 = new HashMap<>();
List<List<Integer>> list = new ArrayList<List<Integer>>();
list.add(new ArrayList<Integer>());
list.add(new ArrayList<Integer>());
for (int i = 0; i < nums1.length; i++){
found1.put(nums2[i], true);
found2.put(nums1[i], true);
}
for (int i = 0; i < nums1.length; i++){
if (found1.get(nums1[i]) == null){
if(!list.get(0).contains(nums1[i]))
{
list.get(0).add(nums1[i]);
}
}
if (found2.get(nums2[i]) == null){
if (!list.get(1).contains(nums2[i])){
list.get(1).add(nums2[i]);
}
}
}
return list;
}
}