We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd5d98d commit c48048dCopy full SHA for c48048d
missing-number/donghyeon95.java
@@ -0,0 +1,19 @@
1
+import java.util.Arrays;
2
+import java.util.Collections;
3
+import java.util.HashSet;
4
+import java.util.Set;
5
+import java.util.stream.Collectors;
6
+
7
+// O(N)
8
+class Solution {
9
+ public int missingNumber(int[] nums) {
10
+ Set<Integer> numSet = Arrays.stream(nums).boxed().collect(Collectors.toSet());
11
12
+ for (int i=0; i<nums.length; i++) {
13
+ if (!numSet.contains(i)) return i;
14
+ }
15
16
+ return nums.length;
17
18
+}
19
0 commit comments