Shortest Grid Path
Hard · rating 1800 · Graphs
The first line has r and c. The next r lines are strings of c characters: 0 is open, 1 is a wall. Moving up/down/left/right through open cells, print the minimum number of steps from the top-left to the bottom-right, or -1 if unreachable. Both corners are open.
Constraints: 1 ≤ r, c ≤ 1000
Related problems
- Course Schedule — Hard
- Count Islands — Hard
- Max Area of Island — Hard