Data Structures & AlgorithmsModerate
How many NON-EMPTY subsets of 1 2 3 4 5 6 7 have bitwise XOR equal to 0?
- A. 16
- B. 63
- C. 15
- D. 14
Correct answer: C. 15
XOR-zero subsets form a linear-algebra family; here the non-empty ones are counted directly by enumerating all 127 subsets. The empty subset also has XOR 0, so it must be removed from the count.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many subsets of exactly two elements of 2 4 5 7 9 10 12 (position pairs) have a sum divisible by 3?
- How many subsequences of EXACTLY four elements of 1 2 3 4 5 6 7 (position subsets) sum to 16?
- How many subsequences of 1 2 3 4 2 2 (position subsets) of size at least 2 have sum EQUAL to their product?
- Remove the MINIMUM possible number of elements from 4 3 5 2 6 so that the remaining elements have a sum of at most 10. How many different…
- How many subsequences of exactly three elements of 1 6 4 9 5 3 (position subsets) have a sum divisible by 5?
- How many contiguous subarrays of 3 5 2 6 1 7 4 8 with length between 2 and 4 inclusive have a sum divisible by 4?