FastPrepFind Two Non-Conflicting Maze Routes
Problems/Find Two Non-Conflicting Maze Routes

Find Two Non-Conflicting Maze Routes

Google logoGoogle● HardNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report first asks for a route from a to A, then adds b to B, and says the routes must not conflict. It corrects the row to aBAb. We read conflict as sharing cells, and we limit the grid so exact simple-path search works. Our version is about 86% the same as the reported question.

A rectangular maze contains walls #, open cells ., starts a and b, and destinations A and B. The four labeled cells are distinct and are traversable.

Decide whether there is a four-direction path from a to A and a four-direction path from b to B such that the two paths share no cell. A path may not repeat a cell.

Return true when such a pair of routes exists.

Function

haveDisjointRoutes(maze: String[]) → boolean

Examples

Example 1

maze = ["...A",".#..","a..#","b..B"]return = true
maze
01230...A1.#..2a..#3b..B

The two agents can use disjoint corridors around the wall.

Example 2

maze = ["aBAb"]return = false
maze
01230aBAb

In the one-row source correction, any routes to the crossing destinations must share a cell.

Example 3

maze = ["a.A","###","b.B"]return = true
maze
0120a.A1###2b.B

Each pair has its own isolated corridor.

Constraints

  • 1 <= rows, columns <= 6.
  • Every row has equal length and contains only #, ., a, A, b, or B.
  • Each of the four labels appears exactly once.

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

  • Swim in Rising WaterUiPath · PHONE SCREEN
  • Sudoku Puzzle SolverConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Choose the Next Minesweeper ActionRunloop · PHONE SCREEN
  • Find the Safest Path in a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Shortest Distance from All BuildingsWaymo · PHONE SCREENWaymo 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
  • Word Search IIApple · PHONE SCREENApple interview questions
  • Sliding PuzzleNVIDIA · PHONE SCREENNVIDIA interview questions
  • Maximum Words in Disjoint Grid PathsIndeed · PHONE SCREENIndeed 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 boolean haveDisjointRoutes(String[] maze) {
        // Write your code here.
    }
}
Checking account…