i have no idea from where its giving problem. please check this out
Rat chases its cheese
as we checked to stay in grid and applied i<0 or j<0 but we didnt do it in rat in maze question. these both are almost same questions
such condition will never arris in rat in maze becuase there we can only move right or down, so numbers will always increment hence remain non negative.
here becuase we can move in all four directions we may hit such i<0 or j<0 conditions
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.