I was asked the following question:
You are given a board game represented as a 2D array of 0's and 1's. 0 stands for passable positions and 1 stands for impassable positions. Design an algorithm to find a path from top left corner to bottom right corner.
For example, for the following board:
0 0 0 0 0 0 0
0 0 1 0 0 1 0
0 0 1 0 1 1 0
0 0 1 0 1 0 1
1 1 1 0 0 0 0
Path: (0,0) -> (0,1) -> (0,1) -> (0,2) -> (0,3) -> (1,3) -> (2,3) -> (3,3) -> (4,3) -> (4,4) -> (4,5) -> (4,6)
Edit: My approach was a DFS with a time complexity of O(MN) and space complexity of O(min(M,N).