43. Count Set Bits
Easy
Given a non-negative integer numero, return how many bits equal to 1 appear in its binary representation, without leading zeros.
Example 1
Input: numero = 13
Output: 3
Explanation: 13 in binary is 1101, which contains three bits equal to 1.
Example 2
Input: numero = 8
Output: 1
Constraints
- 0 <= numero <= 2^31 - 1
Bits
Saved in this browser
Caso 1
numero =
13
Expected =
3
Caso 2
numero =
8
Expected =
1
Run checks these 2 cases. Submit runs all 6, including hidden ones.