Given a list of students with their respective GPAs, return the top 5 students with the highest GPAs. If there are more than 5 students with the same GPA as the fifth highest GPA, include only the first 5 students with that GPA.
Explanation: Step-by-step: First, sort the list of students based on their GPAs in descending order. Then, find the 5th GPA. After that, filter the list to include only the first 5 students with the same GPA as the 5th GPA.
Explanation: Step-by-step: First, sort the list of students based on their GPAs in descending order. Then, find the 5th GPA. After that, filter the list to include only the first 5 students with the same GPA as the 5th GPA.
Arrays
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak