Skip to content

Commit 452ac8f

Browse files
Update Single Number.py
1 parent 703ea5d commit 452ac8f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: Arrays/Easy/Single Number.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
class Solution:
22
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
36
a = 0
47
for i in nums:
58
a ^= i

0 commit comments

Comments
 (0)