Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many non-empty contiguous subarrays of [3, 3, 1, 2, 2, 1] have bitwise XOR equal to 0?

  1. A. 6
  2. B. 4
  3. C. 3
  4. D. 5

Correct answer: D. 5

A subarray has XOR zero exactly when the prefix XOR values at its two ends are equal, so count equal pairs among prefix XORs including the seed 0. The count of such pairs gives the answer.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic