FastPrepWait Time for the Next Customer
Problems/Wait Time for the Next Customer

Wait Time for the Next Customer

Google logoGoogle● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives the service time of each server and the number of people waiting, and asks how long a newly arriving customer waits. We set that servers start idle, that people are assigned first come, first served, and that the time asked for is when service starts. Our version is about 79% the same as the reported question.

There are n servers. Server i takes exactly serviceTimes[i] time units for every customer. All servers are idle at time 0, and waitingPeople customers are ahead of you in one first-come, first-served queue.

Whenever a server is free and the queue is nonempty, the next customer starts immediately. Return the earliest time at which you start service. If a server is already available for you at time 0, return 0.

When several servers finish at the same time, all of those service slots become available at that time.

Function

waitTimeForNextCustomer(serviceTimes: int[], waitingPeople: long) → long

Examples

Example 1

serviceTimes = [5,10]waitingPeople = 0return = 0

Both servers are idle, so you start immediately.

Example 2

serviceTimes = [5,10]waitingPeople = 2return = 5

The two waiting customers start at time zero. The five-unit server frees first.

Example 3

serviceTimes = [3,7]waitingPeople = 5return = 9

Customers ahead start at times 0,0,3,6,7; you take the next slot at time 9.

Constraints

  • 1 <= serviceTimes.length <= 100000.
  • 1 <= serviceTimes[i] <= 1000000.
  • 0 <= waitingPeople <= 10^12.

More Google Onsite Interview questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Koko Eating BananasTekion · ONSITE INTERVIEWTekion interview questions
  • Koko Eating BananasAmazon · ONSITE INTERVIEW
  • Maximum Supplier ProfitExpedia · ONSITE INTERVIEWExpedia interview questions
  • First Register Overflow TickNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Two Eggs: Minimum Worst-Case DropsApple · ONSITE INTERVIEWApple interview questions
  • Find a Function Root by BisectionJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Integer Square RootMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • K-th Amount a Payout Machine Can GiveRippling · ONSITE INTERVIEWRippling interview questions
  • Integer Square Root with Error ChecksBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions

Interview reports that mention this question

  • Google New Grad Onsite, Customer Wait Time: 1 Experience

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long waitTimeForNextCustomer(int[] serviceTimes, long waitingPeople) {
        // Write your code here.
    }
}
Checking account…