FastPrepAverage Grades per Student
Problems/Average Grades per Student

Average Grades per Student

Hartford Financial Services logoHartford Financial Services● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report does not give input limits or say what happens with empty grade lists or repeated names. Our version is about 95% the same as the reported question.

You are given two arrays, names and grades. The list grades[i] contains the integer grades for student names[i].

Compute the arithmetic average grade for every student: the sum of that student's grades divided by the number of grades.

Return an array averages, where averages[i] is the average for student names[i]. This pairs each student name with that student’s average. Preserve the input order; do not sort students or combine grade lists. For example, pairing names[i] with averages[i] reconstructs the name-to-average dictionary.

Return the numerical averages without rounding them to integers or a fixed number of decimal places. Each result is accepted when its relative or absolute error is at most 10^-6.

Function

averageGrades(names: String[], grades: int[][]) → double[]

Examples

Example 1

names = ["Alice","Bob","Charlie"]grades = [[85,90,88],[70,75,80],[65,70,75]]return = [87.66666666666667,75,70]

Alice's grades sum to 263, so her average is 263 / 3. Bob's average is 225 / 3 = 75, and Charlie's is 210 / 3 = 70. The returned values correspond to Alice, Bob, and Charlie in that order.

Example 2

names = ["Zoe","Amy"]grades = [[0,100],[20,40,80]]return = [50,46.666666666666664]

Zoe has average 100 / 2 = 50, and Amy has average 140 / 3. The grade lists have different lengths. Preserve the input order even though Amy comes first alphabetically.

Example 3

names = ["Solo"]grades = [[0]]return = [0]

A student with one grade has that grade as the average, including when the grade is 0.

Constraints

  • 1 <= names.length = grades.length <= 500.
  • Every name is a nonempty string of at most 50 characters, and all names are distinct. Names are case-sensitive.
  • Every grades[i] contains at least one integer.
  • 0 <= grades[i][j] <= 100.
  • The total number of grades across all students is at most 5000.

More Hartford Financial Services interview questions

  • Maximum Product SubarrayONSITE INTERVIEW · Seen Sep 2026
  • Bubble SortONSITE INTERVIEW · Seen Mar 2019
  • Swap Adjacent Character PairsONSITE INTERVIEW · Seen Mar 2019
  • Assign Student Grades from CSV MarksONSITE INTERVIEW
  • Second Highest SalaryONSITE INTERVIEW

Similar questions at other companies

  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Find the Missing Number from 1 to 100NVIDIA · PHONE SCREENNVIDIA interview questions
  • Max Points on a LineUber · PHONE SCREENUber interview questions
  • Count Product-Divisible PairsMotive · PHONE SCREENMotive interview questions
  • Pair Up an Array So Every Pair Sum Divides by kAdobe · PHONE SCREENAdobe interview questions
  • Count Valid Square PairsAuxoAI · OA
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Distinct Products After Removing One ElementHSBC · OAHSBC interview questions
  • Majority ElementMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Count Index Pairs with Equal Value OffsetGoogle · ONSITE INTERVIEWGoogle interview questions
All Hartford Financial Services interview questionsSee Hartford Financial Services hiring insights
Saved
class Solution {
    public double[] averageGrades(String[] names, int[][] grades) {
        // write your code here
    }
}
Checking account…