-
-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy path461.py
More file actions
16 lines (16 loc) · 668 Bytes
/
461.py
File metadata and controls
16 lines (16 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
__________________________________________________________________________________________________
sample 20 ms submission
class Solution:
def hammingDistance(self, x: int, y: int) -> int:
string = bin(x^y)
result = 0
for i in string:
if i == '1':
result += 1
return result
__________________________________________________________________________________________________
sample 12992 kb submission
class Solution:
def hammingDistance(self, x: int, y: int) -> int:
return bin(x^y).count('1')
__________________________________________________________________________________________________