Data Structures & AlgorithmsHardGATE CS · Codeforces Div2 B

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

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

Correct answer: A. 4

Prefix XORs: a subarray XORs to 0 exactly when two prefix XOR values (including the empty prefix 0) are equal, so count equal pairs in a hash map.

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

Exams that ask this topic