Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA
What is the maximum value of a[i] XOR a[j] over index pairs i < j in [3, 10, 5, 25, 2, 8]?
- A. 27
- B. 35
- C. 28
- D. 32
Correct answer: C. 28
A binary trie greedily picks the opposite bit at each level. The best pair is 5 and 25, with 5 XOR 25 = 28.
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
- How many index pairs i < j in [6, 1, 8, 7, 3, 4] have a[i] AND a[j] = 0?
- How many times does the pattern "ababa" occur in the text "ababcababa", counting overlapping occurrences?
- How many palindromic substrings (counting each occurrence by position, length 1 and up included) does "abacaba" contain?
- What is the length of the longest well-formed (balanced) contiguous substring of ")()())"?
- n = 7 people stand in a circle numbered 1 to 7. Starting from person 1, every 3rd remaining person is removed until one remains. Which…
- A linked list holds 1, 2, 3, 4, 5, 6, 7. Reversing each complete group of 3 nodes (leaving a final incomplete group unchanged) gives which…