Highest grade per subject
A gradebook logs retakes as rows "student,subject,score" (score a non-negative integer); the same student-subject pair can appear several times. Produce the flattened grade matrix the report card reads: a dictionary keyed by "student.subject" (the two fields joined with a dot) whose value is that pair's HIGHEST score. Example: ["ava,math,80", "ava,math,92", "raj,art,75"] gives {"ava.math": 92, "raj.art": 75}.
Implement
grade_matrix(rows: list[str]) → dict[str,int]Examples
in
[["ava,math,80","ava,math,92","raj,art,75"]]out{"raj.art":75,"ava.math":92}What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 13 min
solution.py
InputExpectedGot
[["ava,math,80","ava,math,92","raj,art,75"]]{"raj.art":75,"ava.math":92}not run yetsample