Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div2 B

What is the sum of the XOR of every non-empty contiguous subarray of [1, 2, 3]?

  1. A. 10
  2. B. 12
  3. C. 7
  4. D. 14

Correct answer: A. 10

Single elements give 1, 2, 3. The pairs give 3 and 1, and the whole array gives 0. Each subarray is counted once, not once per prefix.

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

Exams that ask this topic