Help Wanted
Write a function that takes an unsigned integer (in binary string form) and returns the number of ‘1’ bits in its binary representation.
My first version of the code:
1 | class Solution { |
这个我看起来问题不大啊,边界条件设置好,n&1 计算最低位是不是 1 ,再加上递归调用 n 的右移1 位。
This looks fine to me. The base cases are set up, n&1 checks whether the lowest bit is 1, plus the recursive call on n shifted right by 1 bit.
摄影师:广元

