Data Structures & AlgorithmsHard

For 5 2 7 1 4 6 3, how many split points i (0 ≤ i ≤ n−2) have XOR(A[0..i]) equal to XOR(A[i+1..n−1])?

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

Correct answer: B. 6

Two parts have equal XOR exactly when the total XOR is zero, since x XOR y equals the total. Here the total XOR is zero, so every split point qualifies and the count is n−1.

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

Exams that ask this topic