Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2

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

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

Correct answer: B. 14

XOR over a subarray is a prefix-XOR difference, so the best subarray XOR is 14. 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