Data Structures & AlgorithmsModerateCodeforces Div 2 C · ICPC regional
Choose a from {6, 9, 12} and b from {3, 5, 10}. What is the largest possible value of a XOR b?
- A. 12
- B. 17
- C. 15
- D. 8
Correct answer: C. 15
Enumerate the nine pairs, or use the highest differing bit greedily. The XOR of 12 and 3 is 15, the largest of the nine values, while AND-based or sum-based choices are different quantities.
More Coding Interview Problems questions
- Tasks AAABBC must be scheduled one per time unit; two identical tasks need at least 2 idle-free units between them (cooldown k = 2, i.e…
- Half-open intervals [1,5), [3,8), [10,12), [11,15). How many integer points lie in at least one of these intervals?
- Array [5, -5, 2, 3, -2, 7, 3]. How many contiguous subarrays have a sum that is 0, 5 or 10?
- Sorted positive array [1, 3, 4, 6, 9, 12]. How many index pairs i < j have a[i] a[j] >= 18?
- How many integers x with 1 <= x <= 64 have a binary representation (without leading zeros) that reads the same forwards and backwards?
- Problem: The suffix array of a string is its suffix start indices sorted by the suffix text. What is the value at position 2 (0-based) for…