Feel free to checkout the image source at the bottom of the page for the original problem description :)
Imagine you're a teacher with a list of student grade records, where each record is written in the format: "[name]: [grade]". Every student has received multiple grades, each ranging between 1 and 5. Your task is to figure out which student has performed the best overall, meaning you need to determine which one has the highest average grade.
Each student has a unique average, so there's no tie to worry about. You'll need to carefully go through the records, calculate the averages, and then identify the top performer. You don’t have to stress about finding the fastest way to do it; as long as the method you use doesn't take too long, you'll be just fine!
Example 1:
Input: records = ["John: 5", "Michael: 4", "Ruby: 2", "Ruby: 5", "Michael: 5"]
Output: "John"
Explanation:Let's calculate students' average grades:
- "John" = 5
- "Michael" = (4 + 5) / 2 = 4.5
- "Ruby" = (2 + 5) / 2 = 3.5
Since 5 > 4.5 > 3.5, the result is "John".
Example 2:
Input: records = ["Kate: 5", "Kate: 5", "Maria: 2", "John: 5", "Michael: 4", "John: 4"]
Output: "Kate"
Explanation:n/a
TO-DO


input:
output: