Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).
If this function is called many times, how would you optimize it?
class Solution:
def hammingWeight(self, n: int) -> int:
count = 0
while n:
count += n%2
n = n//2
return count
2로 나눴을 때 나머지는 0 또는 1
0은 더해져도 의미가 없으니까 나머지를 걍 싹다 더했다
n/2 => 소수점 아래까지 전부 나옴
n//2 => 소수점 아래 다 버리고 오직 몫만
비트연산자를 쓰면 더 간단할까..? 싶지만
비트 계산은 하나도 몰라서 포기~