The k-th biggest number
Reported in interviews at (where)
You are given a list of whole numbers nums and a number k. Line the numbers up from biggest to smallest, keeping repeats, and return the one in place k (counting from 1).
Sorting works. A heap that never holds more than k numbers, or quickselect, does less work.
- Input
nums = [3,9,4,9,1]
k = 2- Output
9
From the top: 9, 9, 4, 3, 1. The second is 9: repeats count.
- Input
nums = [3,9,4,9,1]
k = 3- Output
4
The third from the top is 4.
Limits
1 <= k <= nums.length <= 100000-10000 <= nums[i] <= 10000
Hints
Hint 1
Keep a min-heap of the k biggest seen so far; its top is the answer at the end.
Where this was reported
- American Express, Technology intern on-campus interview, 2023 (GeeksforGeeks)
- Salesforce, Technical support engineer intern on-campus interview, 2023 (GeeksforGeeks)
Our own problem on the task these candidates describe; the wording, examples and tests are InternDoor’s.
Run your code to check it on the examples. Submit runs every hidden test.

