Shortest Path in a Grid (DFS/BFS) with DFS Backtracking + Memo/DP Follow-up

Asked at AppLovin · Coding Questions · Difficulty: Medium

Given a 2D grid with passable cells and obstacles, and two special cells `S` (start) and `T` (target), compute the **length of the shortest path** from `S` to `T` in number of steps. Each move goes to one of the 4 neighbouring cells (up/down/left/right). If `T` is unreachable, return `-1`.

Loading the problem…