Skip to content

Commit

Permalink
Merge pull request SnowScriptWinterOfCode#528 from aishwarya-chandra/…
Browse files Browse the repository at this point in the history
…day21q3

day21q3
  • Loading branch information
bh-g authored Jan 23, 2024
2 parents c1977ad + 00e2ead commit 68abfd4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Day-21/q3: Unique Paths/aishwarya--J.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```
class Solution {
private int traverse(int i, int j, int[][] memo, int m, int n) {
if (i < 0 || j < 0 || i >= m || j >= n) return 0;
if (i == m-1 && j == n-1) return 1;
if (memo[i][j] != 0) return memo[i][j];
memo[i][j] = traverse(i+1, j, memo, m, n) + traverse(i, j+1, memo, m, n);
return memo[i][j];
}
public int uniquePaths(int m, int n) {
var memo = new int[m][n];
return traverse(0, 0, memo, m, n);
}
}
```

0 comments on commit 68abfd4

Please sign in to comment.