Dsa
Heap
Easy
K-Top Scorers
You are given a list of student scores and a positive integer K. Your task is to find the top K scores and return them in ascending order. If there are fewer than K unique scores, return all of them. Input will be provided in a single line containing space-separated integers representing the scores. Output should be the K top scores in ascending order, separated by spaces.
Example:
Input:
4 1 3 5 2 6 3 5 4
Output:
5 6
Key concepts
heappriority queuesorting
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now