Dsa
Bit Manipulation
Medium
Unique Bitmask Count
Given an integer n, find the count of unique integers that can be formed by making bitwise OR operations on all possible subsets of the set of integers from 1 to n. Output the count.
Example:
Input:
3
Output:
4
Explanation: The subsets of {1, 2, 3} give us unique results of 0, 1, 2, 3, 3, and 2 (using OR), which results in 4 unique values: 0, 1, 2, 3.
Key concepts
bit manipulationset operationscounting
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