We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d2b72e7 commit ddd7fc0Copy full SHA for ddd7fc0
Bit Manipulation/Easy/Single Number.py
@@ -0,0 +1,9 @@
1
+class Solution:
2
+ def singleNumber(self, nums: List[int]) -> int:
3
+ #hashmap
4
+ #math -> 2 * (a+b+c) - (a+a+b+b+c) = c
5
+ #bitmasking -> a^0 = a and a^a = 0; a^b^a = a^a^b = 0^b = b
6
+ a = 0
7
+ for i in nums:
8
+ a ^= i
9
+ return a
0 commit comments