Your question is Rat Maze Traversal. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
An Airtel network planning grid is represented by a rectangular matrix. A value of 1 is an open cell, and 0 is blocked. Starting at the top-left cell, (0, 0), reach the bottom-right cell, (rows - 1, cols - 1) by moving up, down, left, or right.
Implement solve_rat_maze(maze) using both DFS and BFS. Return the paths found by each algorithm. DFS may return any valid path, while BFS must return a shortest path. Represent each path as an ordered list of [row, column] coordinates. Return an empty list when no path exists.
Use the deterministic neighbor order: down, right, up, left. Both algorithms must avoid revisiting cells.
maze, a non-empty rectangular list of lists containing only 0 and 1.dfs and bfs. Each value is a coordinate path, or [] if the destination cannot be reached.def solve_rat_maze(maze):