← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Google/Leetcode 191. Number of 1 Bits
CodingOptional
Write a function that takes a non-negative 32-bit unsigned integer and returns the count of bits set to 1 in its binary representation. This count is also known as the population count or Hamming weight.
For instance, the number 11 in decimal is represented as 1011 in binary, which contains three 1 bits.
Example 1:
Input: n = 7 Output: 3 Explanation: 7 in binary is 0b00000111, which has three 1 bits
Example 2:
Input: n = 128 Output: 1 Explanation: 128 in binary is 0b10000000, which has one 1 bit
Example 3:
Input: n = 255 Output: 8 Explanation: 255 in binary is 0b11111111, which has eight 1 bits