Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

How many contiguous subarrays of [1, 2, 3, 3, 2, 1, 4] have a bitwise XOR of exactly 0?

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

Correct answer: C. 5

Equal prefix-XOR values mark zero-XOR subarrays, including the zero prefix. Counting equal pairs of prefix values gives the total.

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

Exams that ask this topic