Skip to content

Commit 75025a3

Browse files
authored
feat: missing number
1 parent 402d2bd commit 75025a3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

missing-number/minji-go.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Problem: https://leetcode.com/problems/missing-number/
3+
Description: return the only number in the range that is missing from the array.
4+
Concept: Array, Hash Table, Math, Binary Search, Bit Manipulation, Sorting
5+
Time Complexity: O(N), Runtime 0ms
6+
Space Complexity: O(1), Memory 45.71MB
7+
*/
8+
class Solution {
9+
public int missingNumber(int[] nums) {
10+
int n = nums.length;
11+
int missing = n;
12+
13+
for(int i=0; i<n; i++){
14+
missing ^= i;
15+
missing ^= nums[i];
16+
}
17+
return missing;
18+
}
19+
}

0 commit comments

Comments
 (0)