FastPrepBest Average Student Score
Problems/Best Average Student Score

Best Average Student Score

Goldman Sachs logoGoldman Sachs● EasyFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Five Goldman Sachs reports describe the task of finding the best-average student, in CoderPad, superday, and technical-screen rounds. They agree on repeated student-score records and the highest average. This version adds a fixed lexicographic tie rule. Our version is about 97% the same as the reported questions. One more report asks about RAM spill, negative scores, overflow, multithreaded aggregation, atomicity, synchronized and ReentrantLock. Those stay as discussion follow-ups. The UTF-16 tie order is something we clarified, not a detail from the reports. This revised version also requires nonempty names to be well-formed Unicode text, including supplementary characters. Isolated or broken UTF-16 surrogates are left out. The reports did not specify that edge.

Each row of records contains a student name followed by one signed integer score written as a decimal string. A student may appear in multiple rows.

Return the name of the student with the greatest arithmetic mean across that student's scores. If several students have exactly the same mean, return the name that comes first in dictionary order.

Compare averages exactly. Do not rely on floating-point rounding.

When you break a tie, compare names by their UTF-16 code units. A shorter name that matches the start of a longer one comes first.

Interview follow-ups

Follow-up: how would you handle records that do not fit in RAM, negative scores, integer overflow and multithreaded processing? Explain an external-sort or spill-partition strategy, how to merge per-student partial sums and counts, and what must be synchronized. In Java, discuss atomicity and synchronized versus ReentrantLock. These are discussion questions only. Your function still gets the whole records array in memory and returns one student name.

Function

bestAverageStudent(records: String[][]) → String

Examples

Example 1

records = [["Alice","90"],["Bob","80"],["Alice","70"],["Bob","100"]]return = "Bob"

Alice has scores 90 and 70, so her average is 80. Bob has scores 80 and 100, so his average is 90. Bob has the higher average.

Example 2

records = [["Zoe","10"],["Amy","10"]]return = "Amy"

Zoe and Amy both have an average of 10, so the averages tie. Amy comes first in dictionary order, so Amy wins.

Constraints

  • 1 <= records.length <= 200000
  • Every row contains exactly two strings: a nonempty name and a valid 32-bit signed integer score.
  • The total score for one student fits in a signed 64-bit integer.
  • Every student name is a well-formed Unicode string made of Unicode scalar values. In UTF-16, each high surrogate is immediately followed by one low surrogate, and no low surrogate appears alone. Supplementary characters are allowed.

More Goldman Sachs Phone Screen questions

  • House Robber IIIPHONE SCREEN · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
  • Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
  • Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Count Staircase WaysPHONE SCREEN · Seen Oct 2026
  • Is a Power of TenPHONE SCREEN · Seen Oct 2026
  • Minimum Traveling Salesperson TourPHONE SCREEN · Seen Oct 2026
  • Square Root with Newton IterationPHONE SCREEN · Seen Oct 2026
  • First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Count Distinct Pairs With Sum KeBay · ONSITE INTERVIEWeBay interview questions
  • Merchant Payout Reserve CalculatorStripe · PHONE SCREENStripe interview questions
  • Price CheckBlue Origin · PHONE SCREEN
  • Majority ElementByteDance · PHONE SCREENByteDance interview questions
  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Find Unique ElementsCisco · PHONE SCREENCisco interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Two SumAmazon · OA · PHONE SCREEN
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public String bestAverageStudent(String[][] records) {
      // write your code here
    }
}
Checking account…