How to restrict the code to provide only one output not every case?

This is my code

So in this ques what we are interested in finding is first we check if right ans exists or not… means if we can go both bottom and right we prefer right as stated in question.
I have made changes in ur code… its working fine now and passing all the test cases…

Got it, thanks for ur help

BTW if my aim is to print only one way out, what changes do i need to do to this code?

code i have sent is printing one output only… otherwise what u can do is return false from base case I tries it, but is not working

are vivek jo ye ques ka logic hai vo to shi kro jo maine btaya upr… rightmost ans ko preference do

got it, thanks for ur help

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.