WA in first two cases


please tell me what’s wrong in this code.

Hello @shubhamgh00,

  1. It is failing for the test case when the last grid is blocked:
    Example:
    5 4
    OXOO
    OOOX
    XOXO
    XOOX
    XXOX
    Your Output:
    1 0 0 0
    1 1 0 0
    0 1 0 0
    0 1 1 0
    0 0 1 1
    Expected Output:
    NO PATH FOUND

  2. The rat can move up and down also:
    Example:
    4 5
    OOXXX
    OXOOO
    OXOXO
    OOOXO
    Expected Output:
    1 0 0 0 0
    1 0 1 1 1
    1 0 1 0 1
    1 1 1 0 1
    Your Output:
    NO PATH FOUND

Hope, this would help.
Give a like, if you are satisfied.

I am able to get output for first test case but not for second can you please help me correct the code.

Hello @shubhamgh00,

Refer the following code:

Hope, this would help.
Give a like, if you are satisfied.

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.