Compute top three scores per student
AppleSoftware Engineer · Technical ScreenLast updated
This interview question evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer for Compute top three scores per student states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
You are given a list of (student_id, score) records. Return, for each student, their highest three scores in descending order. First, describe and implement a general approach without assuming special constraints. Then optimize your method if scores are guaranteed to be integers in the range 0–100. Discuss time and space complexity, how to handle ties, and what to do when a student has fewer than three scores.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.