Count Number of Maximum Bitwise-OR Subsets
A medium-tier problem at 88% community acceptance, tagged with Array, Backtracking, Bit Manipulation. Reported in interviews at Citadel and 0 others.
You need to find how many subsets of an array have the maximum possible bitwise OR value. Citadel has asked this. The trap most candidates fall into is computing the max OR first, then brute-forcing all subsets to count matches. That works, but the real insight is understanding that the maximum OR is fixed the moment you include certain elements, and you can prune the search space by recognizing which bits are already set. At 88% acceptance, this problem rewards clean enumeration logic over raw throughput. If this hits your live OA and you blank on the pruning angle, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Count Number of Maximum Bitwise-OR Subsets"
Count Number of Maximum Bitwise-OR Subsets is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.
Get StealthCoderThe bitwise-OR of any subset is bounded by the OR of the entire array, so start there. Once you know the target OR value, you need to count subsets that achieve it. Backtracking is the obvious route: generate all 2^n subsets, compute the OR of each, and tally those matching the max. The gotcha is that candidates often waste time on subsets that can never reach the max OR because they lack critical bits. You can prune by tracking the current OR at each step and skipping branches where the remaining elements can't possibly set the missing bits. Array size determines feasibility, but enumeration always completes. The pattern sits at the intersection of Bit Manipulation and Backtracking. StealthCoder handles the full enumeration and pruning logic so you don't have to hand-code an off-by-one error under pressure.
Pattern tags
You know the problem.
Make sure you actually pass it.
Count Number of Maximum Bitwise-OR Subsets recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Count Number of Maximum Bitwise-OR Subsets interview FAQ
Is this actually a hard problem or is 88% acceptance rate accurate?+
The high acceptance reflects that the brute-force enumeration path is straightforward once you recognize the pattern. The trick isn't algorithmic depth, it's remembering to compute max OR first and not overthinking pruning. Most failures come from implementation bugs, not conceptual confusion.
What's the difference between this and subset-sum-like problems?+
Subset-sum looks for a target value you're given. Here, you compute the target (max OR) yourself, then count subsets matching it. The bitwise operation also doesn't accumulate linearly like addition, so your pruning intuitions from DP problems don't transfer directly.
How do I avoid timeout on larger inputs?+
Array size is typically capped to keep 2^n feasible (around 15-20 elements). If your input is larger, you're probably overthinking and should just enumerate. Pruning by skipping branches where remaining elements can't set missing bits keeps the constant factor low.
Do I need to handle duplicates or negative numbers?+
The problem input will clarify constraints. Most variants assume non-negative integers and don't explicitly penalize duplicates in the array, but duplicates in the OR result are distinct subsets. Check the problem statement for exact bounds.
Will Citadel or other companies ask follow-ups on this?+
Citadel is the only company in the data requesting this problem. They likely probe your pruning strategy and whether you can code it cleanly without off-by-one errors. Be ready to explain why branches are safe to skip.
Want the actual problem statement? View "Count Number of Maximum Bitwise-OR Subsets" on LeetCode →