Skip to content

Commit 04cf27a

Browse files
authored
Create 448. Find All Numbers Disappeared in an Array.java
1 parent a42b7c2 commit 04cf27a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class Solution {
2+
public List<Integer> findDisappearedNumbers(int[] nums) {
3+
List<Integer> out = new ArrayList<>();
4+
Map<Integer, Boolean> map = new HashMap<>();
5+
for (int i = 1; i <= nums.length; i++) {
6+
map.put(i, false);
7+
}
8+
9+
for (int i : nums) {
10+
map.put(i, true);
11+
}
12+
13+
for (Integer i : map.keySet()) {
14+
if (!map.get(i)) {
15+
out.add(i);
16+
}
17+
}
18+
19+
return out;
20+
}
21+
}

0 commit comments

Comments
 (0)