Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Consider the array [3, 7, 4, 9, 2, 8, 5]. Two selection rounds are performed: first pick the largest value and remove it, then pick the largest of the remaining values and remove it. What is the sum of the two removed values?

  1. A. 10
  2. B. 24
  3. C. 11
  4. D. 17

Correct answer: D. 17

The two largest are 9 and 8, so 17. Summing the first two elements gives 10, three rounds give 24, and 9 + 2 adds the largest and smallest.

More Coding Interview Problems questions

Exams that ask this topic