This question evaluates algorithm design, data-structure selection, and complexity analysis for per-key aggregation and ranking, examining both conceptual understanding and practical implementation considerations in the Coding & Algorithms domain.
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.