Problem
Ask
Submissions

Problem: High Five

Easy
15 min
Explore how to use hash maps to calculate the top five average scores for each student from a list of their scores. Understand how to organize data by student IDs, perform integer division, and return results sorted by the student ID. This lesson helps you develop skills to solve ranking and aggregation problems in coding interviews effectively.

Statement

You are given a list of scores for multiple students, represented as items, where items[i]=[IDi,scorei]items[i] = [ID_i, score_i] indicates the ID of a student (IDi)(ID_i) and their score (scorei)(score_i). Your task is to compute the top five average scores for each student.

Return the result as an array of pairs, result, where result[j]=[IDj,topFiveAveragej]result[j] = [ID_j, topFiveAverage_j] represents the student with ID, IDjID_j, and their corresponding top five average scores. The result should be sorted in ascending order by IDjID_j.

Note: To calculate the top five averages for each student, sum their highest five scores and perform integer division by 55.


Constraints:

  • 1<=1 <= items.length <=1000<= 1000

  • items[i].length ==2== 2

  • 1<=IDi<=10001 <= ID_i <= 1000

  • 0<=scorei<=1000 <= score_i <= 100

  • For each IDiID_i, there will be at least five scores.

Problem
Ask
Submissions

Problem: High Five

Easy
15 min
Explore how to use hash maps to calculate the top five average scores for each student from a list of their scores. Understand how to organize data by student IDs, perform integer division, and return results sorted by the student ID. This lesson helps you develop skills to solve ranking and aggregation problems in coding interviews effectively.

Statement

You are given a list of scores for multiple students, represented as items, where items[i]=[IDi,scorei]items[i] = [ID_i, score_i] indicates the ID of a student (IDi)(ID_i) and their score (scorei)(score_i). Your task is to compute the top five average scores for each student.

Return the result as an array of pairs, result, where result[j]=[IDj,topFiveAveragej]result[j] = [ID_j, topFiveAverage_j] represents the student with ID, IDjID_j, and their corresponding top five average scores. The result should be sorted in ascending order by IDjID_j.

Note: To calculate the top five averages for each student, sum their highest five scores and perform integer division by 55.


Constraints:

  • 1<=1 <= items.length <=1000<= 1000

  • items[i].length ==2== 2

  • 1<=IDi<=10001 <= ID_i <= 1000

  • 0<=scorei<=1000 <= score_i <= 100

  • For each IDiID_i, there will be at least five scores.