Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div 2
Array A = [7, 4, 7, 14, 7, 6, 2]. Over all non-empty contiguous subarrays, what is the maximum value of the XOR of the elements in the subarray?
- A. 12
- B. 15
- C. 47
- D. 14
Correct answer: B. 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
- Rooted tree with root 0 and vertices 0 to 9; the edges are 0–1, 1–2, 1–3, 2–4, 2–5, 4–6, 5–7, 7–8, 0–9 (parent–child). Every edge has…
- Points A(4,4), B(3,6), C(2,6), D(2,3), E(3,5), F(8,4) in the plane. The cost of joining two points is the Manhattan distance |x1−x2| +…
- Undirected simple graph on vertices A, B, C, D, E, F, G with edges A–C (1), B–D (1), B–G (1), C–D (1), C–E (1), D–E (1), E–F (1), E–G (1)…
- Keys [7, 34, 44, 32, 10, 49, 20] are inserted, in this order, into an empty AVL tree using the standard rebalancing (left, right…
- Connected undirected graph on vertices A, B, C, D, E, F, G with edges A–E (1), A–G (1), B–F (1), C–D (1), D–F (1), E–F (1), E–G (1)…
- Coins of denominations [12, 10, 3, 2] are available in unlimited quantity. What is the minimum number of coins needed to pay exactly 30?…