I have a n by n maze, like this:
[0, 1, 0, 0, 0, 1]
[1, 1, 0, 1, 1, 0]
[1, 0, 0, 1, 0, 1]
[0, 1, 1, 0, 0, 1]
[0, 0, 0, 1, 0, 1]
[1, 0, 1, 0, 1, 1]
Only 0-fields are passable, and one can only move directly up, down, left, or right.
I want to find the longest possible cycle-free path from a given point.
I am aware that there are recursive algorithms for this problem, but I was wondering if there are any more efficient algorithms, or any optimizations to the recursive algorithm that I can use?