Problem
Ask
Submissions

Problem: High Five

Medium
30 min
Explore how to use hash maps to efficiently compute the top five average scores for each student from a list of scores. This lesson helps you understand sorting results by student ID and performing integer division on top scores, enhancing your skills in handling array and hash map problems.

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

Medium
30 min
Explore how to use hash maps to efficiently compute the top five average scores for each student from a list of scores. This lesson helps you understand sorting results by student ID and performing integer division on top scores, enhancing your skills in handling array and hash map problems.

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.