I have done it using backtracking two test cases are not passing
Two test cases shows wa
@Krishna-Singh-2678805765519156 read problem statement carefully, rat can go in all four direction but you are only searching for right and down path.
I have move the rat in all four direction. But in the same board I have used 1 for visited X for blocked and 0 for open and not visited. The rat goes checks if its open and not visited and moves further otherwise return false. If for a particular block it cant go anywhere we simply return false before backtracking but still it shows wa on few test cases.
Your code is correct but in output you have to print β1β and β0β you are printing β1β and βOβ thatβs why you are getting WA,update this and your code will work fine.