Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional
Array A = [3, 2, 4, 10, 10, 2]. Over all non-empty contiguous subarrays, what is the maximum value of the XOR of the elements in the subarray?
- A. 15
- B. 10
- C. 14
- D. 31
Correct answer: A. 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.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–B (1), A–D (1), A–F (1), B–C (1), B–D (1), B–F (1), C–E (1), D–E (1)…
- Keys are inserted in the order 48 55 26 32 38 into an empty binary search tree. Then the key 48 (which has two children) is deleted by…
- Words ['b', 'abbb', 'b', 'ca', 'b', 'bac'] are inserted in this order into an empty trie with one node per character, shared prefixes…
- Directed weighted graph on vertices A, B, C, D, E, F with edges listed in this exact order: F→D (3); F→B (3); D→E (1); D→B (2); A→C (7)…
- Tree with vertices 0 to 7, root 0, edges 0–1, 1–2, 0–3, 3–4, 2–5, 5–6, 1–7 (parent–child). Vertex weights (vertex:weight) 0:10, 1:14…
- Distinct keys [10, 21, 12, 26, 19] are inserted, in the order given by the sequence [12, 21, 19, 10, 26], into an empty binary search…