Shortest path in 2d arrays

前端 未结 3 870
暗喜
暗喜 2020-12-19 15:31
*...*..D
.G..*.....
**...**.
.S....*.
........
...G**..
........
.G..*...

Here is 2d array where
S- Source
D-Destination
G-Point must be

3条回答
  •  星月不相逢
    2020-12-19 15:51

    This is a simple Breadth First search algorithm problem. This is called flood fill technique which is a type of Breadth First search algorithm. Read it from here. You can also learn the basic Breadth first algorithm from here. This could also be solved by other techniques like Dijkstra or Floyd warshal. But Breadth first search is easier to understand.

提交回复
热议问题