Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional
How many distinct XOR values arise from index pairs i < j of [1, 2, 3, 4]?
- A. 6
- B. 7
- C. 12
- D. 1
Correct answer: A. 6
The six pair XORs are 3, 2, 5, 1, 6, 7, all distinct, so 6; it equals the pair count here, so the distinct check must still be explicit. 7 is the largest XOR value, 12 counts ordered pairs and 1 is the smallest XOR.
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 non-empty prefixes of "abacaba" are palindromes?
- What is the minimum number of single-character flips needed to turn the binary string "10100101" into a string of the form 0...01...1 (all…
- For [1, -2, 3, 4, -1, 5, -6, 2], you may delete at most one element before taking a maximum sum over non-empty contiguous subarrays. What…
- What is the sum of i j over all pairs 1 <= i < j <= 6?
- How many index triples i < j < k in [2, 3, 5, 7, 8] satisfy a[k] - a[i] <= 4?
- Swap the first two elements of [2, 4, 1, 3, 5], then count the inversions of the new array. What is the count?