Leetcode - Number of 1 Bits (Python)

preview_player
Показать описание
February 2021 Leetcode Challenge
Leetcode - Number of 1 Bits #191
Рекомендации по теме
Комментарии
Автор

Heres my solution:


ones = 0

while n:
ones += n & 1
n = n >> 1

return ones

smartcontractalt
Автор

Thanks a lot; really do appreciate your videos <3

vvxyow
Автор

Thanks for breaking down the concepts in this video. At 1:29 on line 6, the binary number should be 1011. That had me confused for a bit.

s.yirenkyi
Автор

Thanks for solving the problem for us. Could you explain why did you take the 2nd position for the string ?

hotasandeep
welcome to shbcf.ru