Algorithm/1일 1코테

[💕 LeetCode Python] 461. Hamming Distance

대인보우 2020. 10. 27. 13:30
반응형

✍461. Hamming Distance✍


문제

leetcode.com/problems/hamming-distance/

 

Hamming Distance - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

내 답

def hammingDistance(self, x: int, y: int) -> int:
	# xor은 같으면 0, 다르면 1이므로 1의 갯수를 센다.
        return bin(x^y).count('1') 

 

풀이

내 답이랑 똑같음

반응형