Tap here to switch tabs
Problem
Ask
Submissions

Problem: High Five

easy
15 min
Explore how to solve the problem of calculating top five average scores for each student using hash maps. Learn to organize data efficiently, sort results by student ID, and implement solutions suitable for coding interviews. This lesson helps you develop practical skills for handling arrays and hash maps in coding challenges.

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.

Tap here to switch tabs
Problem
Ask
Submissions

Problem: High Five

easy
15 min
Explore how to solve the problem of calculating top five average scores for each student using hash maps. Learn to organize data efficiently, sort results by student ID, and implement solutions suitable for coding interviews. This lesson helps you develop practical skills for handling arrays and hash maps in coding challenges.

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.