I am trying a simple recursive approach here. From each dimension, I am checking whether or next I can move forward to next dimension. If so I am moving there and return back to the present position to check whether backward movement is possible or not.
Problems I am facing :
- If I comment out one recursion (either), the answer becomes zero.
- If both recursions are present then it is infinite loop
- In first if statement if I remove arr*-- or in second if I remove arr*++, I am getting wrong answer (but no infinite loop or zero as the answer).
Where have I gone wrong? Please help
p.s. Is there any other approach for this problem?