What is the error in my code?

hi @goyalvivek
refer this -->

yes, but what is the error in mine?

ur corrected code -->

@goyalvivek
is there anything else??

please explain the error

@goyalvivek
u will have to print the ans in base case only… else u will have to use another array to store the ans, then print in main…

But my code gives error /bin/run.sh: line 4: 18 Segmentation fault

please explain this base case ==> if(maze[i][j] == ‘X’ || ans[i][j]) return false;

why does the base case have ans[i][j] ???

this is because you stuck in a loop
first go left then up and then right then down and so on…

you also have to handle this case

to handle this case
use this condition
if(sol[i][j]==1) return false;

Got it, https://ide.codingblocks.com/s/653454 BUT still unable to clr all testcases

i have already shared corrected code above… refer it…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

i have already shared corrected code which is codeprozone.com