Rat in a maze in java

There is a N*N maze . You are given binary matrix ” maze[N-1][N-1] ” .

A rat starts from maze[0][0] and it wants to go to the position ” maze[N-1][N-1] ” .

rat can move left, right, up and down.

“1” means rat can move to that position. And “0” means rat can not move to that position. Rat in a maze is very important question from data structures point of view. You can learn more about data structures on this tutorial.

Below is our maze.  We want our rat to reach goal by going through the path which has value “1”  only.


Here is the java code for rat in a maze.

If you have any questions or comments , feel free to post here. :)

All the best.

cheers !!