Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional

How many unordered pairs of positions in [5, 1, 4, 7, 2, 6] have bitwise XOR at most 3?

  1. A. 9
  2. B. 4
  3. C. 11
  4. D. 7

Correct answer: D. 7

Insert values into a binary trie and, for each element, count earlier values whose XOR with it is at most K by walking the bits of K. Counting pairs with a sum at most K answers a different question.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic