Skip to content

Commit 7b48d1e

Browse files
Path Restrictions
1 parent c29e0df commit 7b48d1e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Recursion/Backtracking/PathObs.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
static void pathRestrictions(String p, boolean[][] maze, int r, int c) {
2+
if (r == maze.length - 1 && c == maze[0].length - 1)
3+
System.out.println(p);
4+
return;
5+
6+
if (!maze[r][c])
7+
return;
8+
9+
if (r < maze.length - 1)
10+
pathRestrictions(p + 'D', maze, r+1, c);
11+
12+
if (c < maze[0].length - 1)
13+
pathRestrictions(p + 'R', maze, r, c+1);
14+
15+
}

0 commit comments

Comments
 (0)