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 452ac8f commit d2b72e7Copy full SHA for d2b72e7
Bit Manipulation/Easy/Missing Number.py
@@ -0,0 +1,18 @@
1
+class Solution:
2
+ def missingNumber(self, nums: List[int]) -> int:
3
+ '''
4
+ num_dict = {}
5
+ for num in nums:
6
+ if num not in num_dict:
7
+ num_dict[num] = 1
8
+
9
+ for num in range(len(nums)+1):
10
11
+ return num
12
+ #hash_map approach, works fine
13
14
+ #bit manipulation
15
+ missing = len(nums)
16
+ for i in range(len(nums)):
17
+ missing ^= i^nums[i]
18
+ return missing
0 commit comments