FastPrepMaximum-Clearance Path From a Point
Problems/Maximum-Clearance Path From a Point

Maximum-Clearance Path From a Point

Google logoGoogle● HardNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report and the original author's replies define the follow-up like this: over all paths from start to target, maximize the path's smallest straight-line (L2) distance to one given point. The path does not need to be the shortest. We fixed four-direction movement, what cells mean, the output precision, and reachability. Our version is about 91% the same as the clarified reported question.

You are given a rectangular binary grid, two open cells start and target, and a reference cell reference. A cell containing 1 is open and a cell containing 0 is a wall.

A path may move one cell up, down, left, or right through open cells and may not repeat a cell. Its clearance is the shortest straight-line (Euclidean) distance from a cell on the path to reference.

Return the maximum clearance among all paths from start to target. An answer within 10^-6 is accepted. A valid path is guaranteed to exist; reference may itself be open or blocked.

Function

maximumClearancePath(grid: int[][], start: int[], target: int[], reference: int[]) → double

Examples

Example 1

grid = [[1,1,1],[1,1,1],[1,1,1]]start = [0,0]target = [0,2]reference = [2,1]return = 2.0
grid
012011111112111

The top-row path stays at least distance 2 from the reference. Any detour lower in the grid comes closer.

Example 2

grid = [[1,1,1],[1,1,1],[1,1,1]]start = [0,0]target = [2,2]reference = [1,1]return = 1.0
grid
012011111112111

A boundary path avoids the reference itself but must use a cell one unit away.

Example 3

grid = [[1,0,1],[1,1,1],[0,0,1]]start = [0,0]target = [2,2]reference = [2,0]return = 1.0
grid
012010111112001

The walls force the path through [1,0], whose distance from the reference is 1.

Constraints

  • 1 <= rows,cols <= 500.
  • Every grid cell is 0 or 1.
  • start, target, and reference are valid zero-based coordinates.
  • start and target are open and connected by at least one open-cell path.

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
  • Swim in Rising WaterUiPath · PHONE SCREEN
  • Find the Safest Path in a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Sliding PuzzleNVIDIA · PHONE SCREENNVIDIA interview questions
  • Trapping Rain Water IIBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Concurrent Web Crawler SimulationOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Minimize CommuteDatabricks · OA · PHONE SCREENDatabricks interview questions
  • Count Connected IslandsUber · PHONE SCREENUber interview questions
  • Shortest Path with Directional Move CostsThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Number of IslandsSpaceX · PHONE SCREENSpaceX interview questions

Interview reports that mention this question

  • Google PhD MLE New Grad Phone Screen: 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 double maximumClearancePath(int[][] grid, int[] start, int[] target, int[] reference) {
        // Write your code here.
    }
}
Checking account…