Data Structures & AlgorithmsHardProduct company OA · Amazon/Microsoft-style OA
How many non-empty subsets of {1, 2, 3, 4, 5, 6} have an XOR of their elements that is at least 4?
- A. 35
- B. 32
- C. 30
- D. 31
Correct answer: B. 32
Count with a bit DP over the achievable XOR values, adding one element at a time, then sum the counts for values 4 to 7. Including the empty subset, whose XOR is 0, does not change this total, but misreading 'at least' as 'greater than' does.
More Coding Interview Problems questions
- How many subsets (including the empty subset) of the values [2, 3, 5, 7, 11, 13, 4, 6] have a sum between 10 and 20 inclusive?
- The values [7, 4, 9, 2, 6, 5] are distributed among two groups (each value goes to exactly one group, any group may be empty). What is the…
- Closed intervals [1,3], [2,6], [3,5], [4,8], [7,9], [9,11], [10,12]. Two intervals conflict if they share any point, endpoints included…
- Half-open intervals [0,4), [1,3), [2,6), [5,7), [6,9), [8,10). What is the minimum number of integer points such that every interval…
- Tasks are (deadline, duration): (3, 1), (2, 2), (4, 3), (5, 2), (1, 1). Tasks run one after another from time 0 without preemption, and a…
- Split the array [7, 2, 5, 10, 8, 4, 6] into 3 non-empty contiguous parts so that the largest part sum is as small as possible. What is…