Data Structures & AlgorithmsHard

How many index pairs i < j in 3 5 6 1 4 2 satisfy A[i] OR A[j] = 6, the maximum value of the array?

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

Correct answer: D. 3

The OR of two values is at least each of them, so the test compares the bitwise union against the maximum directly. Using AND, a ≥ bound, or XOR measures different relations.

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

Exams that ask this topic