191. Number of 1 Bits
Easy
Problem:
Input: n = 00000000000000000000000000001011
Output: 3
Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits.What to learn:
Variable swap using XOR
>>> x = 10
>>> y = 40
>>> (x^y)^x
40
>>> (x^y)^y
10Solution:
Counting the number of ones
Bit operation
Last updated