Your question is Find Top N Performers. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Pearson assessment results arrive as a list of student records. Given the records and an integer n, return the IDs of the top n performers without fully sorting a potentially large list.
A performer with a higher score ranks above one with a lower score. If scores are tied, preserve the students' original input order. Return the selected IDs ordered from highest score to lowest score, with tied students in their original order.
Implement top_performers(students, n).
students, a list of dictionaries with unique string student_id and integer score fields; n, a positive integer.n student ID strings, ranked according to the rules above.Use an approach that is more efficient than sorting the entire list when n is much smaller than the number of students.
def top_performers(students, n):