Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Find the k-th largest element of [3, 2, 1, 5, 6, 4] for k = 2 (1-indexed among values, with duplicates counted separately).

  1. A. 6
  2. B. 5
  3. C. 4
  4. D. 7

Correct answer: B. 5

A size-k min-heap holds the k largest values, so its root is the k-th largest. Sorting ascending and reading index k gives the k-th smallest instead.

More Coding Interview Problems questions

Exams that ask this topic