The base BFS I had was fine but the one-way cell part tripped me up for a bit.
Explain that BFS still works but neighbor generation must respect the directional constraint: from a one-way cell, only the forced direction is allowed. Emphasize that the core BFS structure (queue, visited set, distance tracking) remains unchanged, and the shortest path guarantee holds because all edges have unit weight.
Pro tip: Mention that you would clarify the exact semantics of one-way intersections (e.g., whether they override normal movement or only apply when entering) and test edge cases like a one-way cell pointing off-grid or creating a dead end.
Confirm the grid representation, what a one-way intersection looks like, and whether movement is restricted only when leaving that cell. Ask about edge cases such as one-way cells at borders or unreachable targets.
In the BFS loop, when processing a cell, check if it is a one-way intersection. If so, only consider the forced direction as a valid neighbor; otherwise, consider all four directions.
Keep the queue, visited set, and distance tracking unchanged. Ensure that each cell is enqueued at most once and that distances are updated correctly.
Test scenarios like one-way cells pointing into walls, cycles formed by one-way cells, and grids where the target is unreachable. Verify that the algorithm still returns the shortest path when one exists.
State that time and space complexity remain O(rows * cols) because each cell is processed once and neighbor checks are constant time.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.