I get TLE on testcase 16 i think my algorithm is true but i need tips to improve the speed of the algorithm
some useful hints if you will help me:
1-I use recursive function but i make global varible called ct which count the steps .
2-I mark visited cell with '#' on the same matrix.
3-I make global variable called dr ,i save the last direction on it.
so R RRL L and last direction L i will ignore the value of the cells RRL
4-Every iteration i pick cell and make recursive call on it,i make ct=0 and i send matrix by value not by reference.
if my approach totally wrong please tell me the true approach
Click Here to see my code
Thanks in advanced.