-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path137.py
25 lines (24 loc) · 854 Bytes
/
137.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
__________________________________________________________________________________________________
sample 48 ms submission
class Solution:
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
a = 0
b = 0
for n in nums:
last_b = b
b = ~a & (b^n)
a = (a^last_b) & (a^n)
return ~a & b
__________________________________________________________________________________________________
sample 13944 kb submission
class Solution:
def singleNumber(self, nums: List[int]) -> int:
a, b = 0, 0
for c in nums:
a, b = (~a & b & c) | (a & ~b & ~c), (~a & b & ~c) | (~a & ~b & c)
return b
__________________________________________________________________________________________________