FastPrepRestaurant Waitlist
Problems/Restaurant Waitlist

Restaurant Waitlist

Google logoGoogle● HardNEW GRADPHONE SCREENONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source supplies add, delete, and serve operations and emphasizes explicit assumptions. Party fields, FIFO matching, and finite execution rules are defined for practice; the judged task matches at about 91%.

Process operations against an initially empty restaurant waitlist.

  • JOIN id size adds a party with a unique string ID and positive party size to the back of the waitlist.
  • DELETE id removes the named party, which is guaranteed to be waiting.
  • SERVE tableSize removes and returns the earliest still-waiting party whose size is at most tableSize. Return NONE when no party fits.

Only SERVE operations produce output. Return those party IDs in operation order.

Function

processWaitlist(operations: String[][]) → String[]

Examples

Example 1

operations = [["JOIN","A","4"],["JOIN","B","2"],["JOIN","C","6"],["SERVE","3"],["DELETE","A"],["SERVE","6"],["SERVE","10"]]return = ["B","C","NONE"]

Party B is the first party that fits a table of size 3. After deleting A, party C is served next.

Example 2

operations = [["JOIN","P1","5"],["JOIN","P2","2"],["JOIN","P3","2"],["SERVE","2"],["SERVE","5"]]return = ["P2","P1"]

P2 is earlier than P3 among parties that fit size 2. The next table can seat the earlier remaining party P1.

Constraints

  • 1 <= operations.length <= 100000.
  • Party IDs contain letters or digits, have length from 1 through 20, and are unique across the entire operation sequence.
  • Party sizes and table sizes are integers from 1 through 100000.
  • Every DELETE operation names a currently waiting party.

More Google problems

  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String[] processWaitlist(String[][] operations) {
        // Write your code here.
    }
}
Checking account…