Converging Maze: Nearest meeting cell
Reported by candidates from Juspay's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Juspay's May OA included a graph traversal problem where two entities start at different positions in a maze and need to meet at the nearest cell. You're looking at a breadth-first-search problem disguised as a pathfinding question. The trap is overthinking it as a shortest-path problem for both actors simultaneously. The actual task is simpler: find the cell that minimizes the maximum distance from both starting points. Knowing the pattern matters because BFS is your only real option here, and coding it cleanly under pressure is where most candidates slip. StealthCoder can feed you the template if your brain locks.
Pattern and pitfall
The converging maze problem asks you to find a single meeting cell where two agents starting from different positions can reach with minimal total time or, more likely, minimal maximum time. This is a multi-source BFS variant. Standard BFS finds shortest paths from one source. Here you run BFS from both starting positions simultaneously or sequentially, compute distances to every cell from each source, then find the cell where the larger of the two distances is smallest. The trick is recognizing that you don't need to simulate movement in lockstep. Instead, precompute distances from both sources independently, iterate through all cells, and pick the bottleneck cell. Common mistake: candidates implement multi-agent simulation instead of distance precomputation, blowing time and logic. If you blank on the exact formulation mid-OA, StealthCoder delivers the BFS loop and distance tracking without noise.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Converging Maze: Nearest meeting cell cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as walls and gates. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Juspay's OA.
Juspay reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Converging Maze: Nearest meeting cell FAQ
Is this asking for the meeting time or the meeting cell?+
The problem asks for the cell where they meet soonest when both move optimally. You return the cell itself, not the time. The time is implicit in finding the cell with minimum maximum distance from both sources.
Do they move simultaneously or take turns?+
Treat them as moving simultaneously. Both cover one cell per step. The meeting cell is the one reachable in the fewest steps from the farther starting point. Use BFS distance arrays, not simulation.
What if multiple cells tie for best meeting point?+
Return the lexicographically smallest cell (row first, then column) or follow the problem statement exactly. Check the output format in the problem text carefully. Juspay typically specifies this.
Can the maze have obstacles or walls?+
Likely yes. BFS handles obstacles naturally. Mark blocked cells as unvisited and skip them. If the input gives you a grid with walls, treat them as barriers during the BFS traversal.
How do I optimize if the maze is huge?+
Don't. BFS is linear in grid size. If performance is tight, you've written it wrong. Standard BFS with two distance arrays runs in O(rows * cols) time. That's optimal for this problem.