Showing TLE error


can you just tell where my code is taking time as output is coming correct

@J20APPPP0006
You are getting TLE because you are visiting same index again and again in the path. just add
if(output[i][j]==1){ return false; } in the beginning of rat() function. Your work will work fine.