FastPrepPlace a Service Table Near All Customers
Problems/Place a Service Table Near All Customers

Place a Service Table Near All Customers

Google logoGoogle● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report defines wall, empty, and customer cells and asks for the empty cell with the smallest total distance. We made movement, the output for unreachable cells, and tie-breaking explicit. Our version is about 91% the same as the reported question.

A rectangular restaurant grid contains 0 for an empty cell, 1 for a customer table, and -1 for a wall.

Choose one empty cell for a service table. Movement is allowed one cell up, down, left, or right and cannot pass through walls. Minimize the sum of shortest-path distances from the service table to every customer table.

Return the chosen coordinate [row,column]. Break ties by smaller row, then smaller column. Return [-1,-1] if there is no customer table or no empty cell can reach every customer table.

Function

bestServiceTable(grid: int[][]) → int[]

Examples

Example 1

grid = [[1,0,0],[0,-1,0],[0,0,1]]return = [0,1]
grid
012010010-102001

The cells [0,1] and [1,0] both have total distance four; row-major tie-breaking chooses [0,1].

Example 2

grid = [[1,-1,0],[0,-1,1],[0,0,0]]return = [1,0]
grid
01201-1010-112000

Among cells reaching both customers, [1,0] minimizes the total distance.

Example 3

grid = [[1,-1,0],[-1,-1,1],[0,0,0]]return = [-1,-1]
grid
01201-101-1-112000

No empty cell can reach both customers.

Constraints

  • 1 <= rows, columns <= 200.
  • Every cell is -1, 0, or 1.
  • The grid contains at least one customer table.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Shortest Travel Time in a Grid with Traffic LightsWaymo · PHONE SCREENWaymo interview questions
  • Shortest Path in a Blocked GridSpotify · PHONE SCREEN
  • Shortest Path in a Binary MatrixMeta · PHONE SCREENMeta interview questions
  • Shortest Grid Path With One Wall BreakAmazon · PHONE SCREEN
  • Shortest Path to Food with DirectionsZip · PHONE SCREENZip interview questions
  • Shortest Path in a Grid with Obstacles EliminationMercor · PHONE SCREENMercor interview questions
  • Shortest Path in a Grid with Obstacles EliminationBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Fire Station Response BillLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Minimum MovesHarness · OA
  • Shortest Increasing Path to a TargetUber · ONSITE INTERVIEWUber interview questions

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
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int[] bestServiceTable(int[][] grid) {
        // Write your code here.
    }
}
Checking account…