Skip to content

Commit 156d0a2

Browse files
461.Hamming_Distance
Awesome use of XOR ^
1 parent ee80cf3 commit 156d0a2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

461.Hamming_Distance.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'''
2+
Awesome use of XOR ^
3+
'''
4+
from itertools import zip_longest
5+
class Solution:
6+
def hammingDistance(self, x, y):
7+
"""
8+
:type x: int
9+
:type y: int
10+
:rtype: int
11+
"""
12+
return(bin(x^y).count('1'))

0 commit comments

Comments
 (0)