Skip to content

Instantly share code, notes, and snippets.

View alice17's full-sized avatar
🎯
Focusing

Alice Valentini alice17

🎯
Focusing
View GitHub Profile
f (int) ->
# hamming weight
# time complexity O(log(n))
def hamming_weight(num: int) -> int:
res = 0
while num > 0:
is_odd = num & 1 # 1 (true) if odd, 0 otherwise