Question bank › Bit Manipulation
Dsa Bit Manipulation Medium

Count Active Bits

You are given a non-negative integer n. Your task is to count the number of active (set) bits in the binary representation of n. Input: A single integer n (0 <= n <= 10^9). Output: An integer representing the count of set bits in n. Example: Input: 7 Output: 3 Explanation: The binary representation of 7 is '111' which has 3 set bits.

Key concepts

bit manipulationcounting bitsbinary representation

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.