Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

Array A = [3, 11, 10, 2, 3, 8, 6]. Over all non-empty contiguous subarrays, what is the maximum value of the XOR of the elements in the subarray?

  1. A. 11
  2. B. 14
  3. C. 15
  4. D. 43

Correct answer: C. 15

XOR over a subarray is a prefix-XOR difference, so the best subarray XOR is 15. Kadane's sum, the single largest element, or XOR of arbitrary (non-contiguous) pairs answer different questions.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic