Find Two Non-Conflicting Maze Routes
Updated
Problem statement
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[]) → booleanExamples
Example 1
maze = ["...A",".#..","a..#","b..B"]return = trueThe two agents can use disjoint corridors around the wall.
Example 2
maze = ["aBAb"]return = falseIn the one-row source correction, any routes to the crossing destinations must share a cell.
Example 3
maze = ["a.A","###","b.B"]return = trueEach pair has its own isolated corridor.
Constraints
1 <= rows, columns <= 6.- Every row has equal length and contains only
#,.,a,A,b, orB. - 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