Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 C
Problem: How many subarrays of [1, 2, 3, 0, 3, 2, 1] have a XOR of zero?
- A. 8
- B. 7
- C. 1
- D. 3
Correct answer: A. 8
Prefix XORs are 0, 1, 3, 0, 0, 3, 1, 0; equal values bound zero-XOR subarrays: C(4,2) + C(2,2) + C(2,2) = 6 + 1 + 1 = 8. Skipping the single-element [0] gives 7, testing sum instead of XOR gives 1, and counting only subarrays that start at index 0 gives 3.
More Coding Interview Problems questions
- Problem: How many integers from 1 to 50 have exactly two 1-bits in their binary representation?
- Problem: What is the sum of the decimal digits of 9⁹?
- Problem: Arrange the numbers 3, 30, 34, 5, 9 so that their decimal concatenation is the largest possible number. What is that largest…
- Problem: Minimum number of jumps to reach the last index of [2, 3, 1, 1, 4] when from index i you may jump up to a[i] steps forward. What…
- Problem: Find the k-th largest element of [3, 2, 1, 5, 6, 4] for k = 2 (1-indexed among values, with duplicates counted separately).
- Problem: The intervals [1,3], [2,4], [3,6], [7,8], [5,9], [8,10] are given. What is the minimum number of intervals to remove so that the…