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?
- A. 15
- B. 14
- C. 50
- 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.
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 graph on vertices A, B, C, D, E, F with edges A–C (1), A–D (1), A–E (1), B–D (1), B–F (1), C–D (1), C–F (1), D–E (1), D–F (1)…
- 2 × 3 sliding puzzle with tiles 1 to 5 and one blank (shown as ). Current board: 4 1 / 2 5 3. Goal board: 1 2 3 / 4 5 . A move slides a…
- Undirected weighted graph on vertices A, B, C, D, E with edges A–B (1), A–C (2), A–E (2), B–C (2), C–D (1), C–E (3). How many distinct…
- Connected undirected weighted graph on vertices A, B, C, D, E with edges A–B (3), A–C (3), B–C (3), B–D (3), C–D (1), C–E (4). Among all…
- Connected undirected graph on vertices A, B, C, D, E, F, G, H with edges A–D (1), A–E (1), B–D (1), B–E (1), B–G (1), C–D (1), C–H (1)…
- A binary tree with distinct letters has preorder FBGCHAED and inorder GHACBDEF. What is its postorder traversal (left, right, root)…