Title Description
An integer that indicates the number of the output of the binary number 1 in. Wherein a negative number indicates a complement.
Thinking
And itself after a different number may be 1 or eliminate rightmost 1
Code
# - * - Coding: UTF-. 8 - * - class Solution: DEF NumberOf1 (Self, n-): # erase a rightmost. 1 COUNT = 0 IF n-< 0: n- = n-0xFFFFFFFF & the while n-: n- = ( n--. 1) & n- COUNT + =. 1 return COUNT