Skip to content

Commit 0b6fe20

Browse files
authored
Merge pull request #35 from VinayKumar1512/main
Print Maze Paths
2 parents 9dda5aa + 16722e2 commit 0b6fe20

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

PrintMazepath.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
package recursion;
3+
4+
5+
public class PrintMazepath {
6+
7+
public static void printmazepath(int cr,int cc,int er,int ec,String ans){
8+
9+
if(cr==er && cc==ec){
10+
System.out.println(ans);
11+
return;
12+
}
13+
14+
if(cr>er || cc>ec){
15+
return;
16+
}
17+
18+
printmazepath(cr,cc+1,er,ec,ans +"H");
19+
20+
printmazepath(cr+1,cc,er,ec,ans +"V");
21+
22+
printmazepath(cr+1,cc+1,er,ec,ans +"D");
23+
24+
25+
}
26+
27+
28+
public static void main(String[] args) {
29+
printmazepath(0,0,2,2,"");
30+
}
31+
32+
}

0 commit comments

Comments
 (0)