Skip to content

Latest commit

 

History

History

0191-number-of-1-bits

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

191. Number of 1 Bits

Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).

Example:

Input: n = 00000000000000000000000000001011
Output: 3
Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits.

Constraints:

  • The input must be a binary string of length 32