See the image for problem statement.

What I was thinking was doing either a BFS or DFS appraoch. It's sort of like Unique Paths II, but it's not. It's sort of like Number of Islands, but it's not.

I was thinking of starting with the end position, and if I can get to a cell, mark it in some data structure (possibly re-using visited). If there's a difference between open cells and the cells visited, then we know it to be false. Anyone have any ideas?

image

Comments (1)