Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many index pairs i < j in [6, 1, 8, 7, 3, 4] have a[i] AND a[j] = 0?

  1. A. 0
  2. B. 9
  3. C. 2
  4. D. 8

Correct answer: D. 8

Two numbers AND to zero when they share no set bit, so checking all 15 pairs directly is reliable. Counting pairs whose AND is 1 is a different count.

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

Exams that ask this topic