Passing students by best attempt

Write codeMedium16 min

Your task

A gradebook stores students as two parallel columns: ids (integer student ids) and names (names, same order, all distinct). Quiz attempts arrive separately as rows "id,score", a student may have several attempts or none, and rows may reference unknown ids (ignore those). A student passes when their BEST attempt is at least threshold. Return the passing students' names, sorted alphabetically. Example: ids [101, 102, 103], names ["ava", "raj", "mia"], attempts ["101,72", "102,88", "101,95", "103,60"], threshold 80 give ["ava", "raj"].

Examples

passing_students(ids: list[int], names: list[str], attempts: list[str], threshold: int) -> list[str]
Example 1
Inputpassing_students([101, 102, 103], ["ava", "raj", "mia"], ["101,72", "102,88", "101,95", "103,60"], 80)
Output["ava", "raj"]