- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1460.java
24 lines (22 loc) · 687 Bytes
/
_1460.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
packagecom.fishercoder.solutions.secondthousand;
importjava.util.HashMap;
importjava.util.Map;
publicclass_1460 {
publicstaticclassSolution1 {
publicbooleancanBeEqual(int[] target, int[] arr) {
Map<Integer, Integer> map = newHashMap<>();
for (intnum : target) {
map.put(num, map.getOrDefault(num, 0) + 1);
}
for (intnum : arr) {
map.put(num, map.getOrDefault(num, 0) - 1);
}
for (intkey : map.keySet()) {
if (map.get(key) != 0) {
returnfalse;
}
}
returntrue;
}
}
}