Dev
Mentor
Coach Interview AI
Mock Interview AI
Coding Problems
Blog
Pricing
Toggle theme
Sign In
Get Started
Toggle theme
Loading...
For the best coding experience, use a desktop browser.
Easy
Array
Number of 1 Bits
Return the number of set bits in the binary representation of
n
.
Examples
Input:
n = 11
Output:
3
1011 has three 1 bits.
Sample Test Cases
Case 1 Input:
11
Expected:
3
Case 2 Input:
128
Expected:
1
Reset
Run
Submit
Loading editor...
Test Case
Output
Submission
Case 1 Input:
11
Expected:
3
Case 2 Input:
128
Expected:
1