What's the fastest way to find deepest path in a 3D array?

后端 未结 4 2387
遇见更好的自我
遇见更好的自我 2021-02-14 15:34

I\'ve been trying to find solution to my problem for more than a week and I couldn\'t find out anything better than a milion iterations prog, so I think it\'s time to ask someon

4条回答
  •  天命终不由人
    2021-02-14 16:03

    You can observe it as a graph where (non-diagonal) adjacent elements are connected if they both empty (part of a cave). Note that you don't have to convert it to a graph, you can use normal 3d array representation.

    Finding caves is the same task as finding the connected components in a graph (O(N)) and the size of a cave is the number of nodes of that component.

提交回复
热议问题