Loading...
The Bit Counter
A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- easy
- Seniority
- junior, mid
Problem
A hardware diagnostics tool needs to count how many bits are set to 1 in the binary representation of an integer. Given a non-negative integer n, return the count of 1-bits (also known as the Hamming weight) without converting to a binary string.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.