Data Structures & AlgorithmsHard

How many index pairs i < j in 4 9 2 7 5 3 8 have A[i] + A[j] strictly greater than the MEDIAN of the whole array (the median is the middle value after sorting)?

  1. A. 21
  2. B. 0
  3. C. 15
  4. D. 20

Correct answer: D. 20

The median is a single value used as a threshold, so each pair's sum is compared to it directly. Using ≥, counting the complement, or testing the larger element alone each answer a different question.

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

Exams that ask this topic