Question bank › Bit Manipulation
Dsa Bit Manipulation Hard

Count Unique Bit Patterns

Given an integer `n`, count the number of unique bit patterns that can be generated using exactly `k` bits set to 1. The value of `k` can range from 0 to the number of bits in `n`. You need to output the count of unique patterns. Example: Input: 12 2 Output: 6 // Explanation: 12 in binary is 1100. The unique patterns with exactly 2 bits set to 1 are: 1100, 1010, 1001, 0110, 0101, 0011.

Key concepts

bit_manipulationcountingcombinations

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.