Data Structures & AlgorithmsHardCodeforces Div2 C · TCS NQT
What is the largest XOR value obtainable as the XOR of a non-empty contiguous subarray of [8, 1, 2, 12, 7, 6]?
- A. 36
- B. 14
- C. 15
- D. 37
Correct answer: C. 15
Brute force over all O(n²) subarrays keeps running XORs; the sum-based Kadane answer is a different quantity, because XOR does not add. Taking XOR of the whole array is only one candidate.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the length of the longest arithmetic subsequence (equal consecutive differences, chosen by index) of [3, 6, 9, 12, 5, 10, 15, 20…
- Delete at most ONE element from [1, 3, 2, 5, 4, 6, 9, 7, 8] (or none). What is the length of the longest strictly increasing subsequence…
- From the array [5, 1, 8, 2, 9, 3, 7, 4], choose exactly 3 elements (by index) so that no two chosen indices are adjacent, and maximise…
- How many inversions does the array [2, 4, 1, 3, 5] have? An inversion is a pair of positions i < j with a[i] > a[j].
- What is the minimum number of elements you must INSERT into [1, 4, 2, 7, 4, 1, 3] (at any positions) so that the array becomes a palindrome?
- How many contiguous subarrays of length at least 2 of [23, 2, 4, 6, 7] have a sum that is a multiple of 6?