Hello,
I have a solution for this question without using memoization - that is, without changing the values in the 'mem' list. I base my solution on the fact that once I visited the 'i'th cell (that is, visited[i] == true) there is no need to come back to it, seeing as either left or right works, and if that cell has already been visited, the appropriate truth value has already been returned, and everything is combined via an 'or' statement. My solution is O(n) both timewise and spacewise, so I see no fault in it.
Thanks for your quick reply,
Tal.
Do I have to use Memoization?