Skip to content

Commit 5b0bed6

Browse files
committed
unique paths solution
1 parent fcababd commit 5b0bed6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

unique-paths/hyer0705.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function uniquePaths(m: number, n: number): number {
2+
const dp: number[][] = Array.from({ length: m }, () => Array(n).fill(1));
3+
4+
for (let i = 1; i < m; i++) {
5+
for (let j = 1; j < n; j++) {
6+
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
7+
}
8+
}
9+
10+
return dp[m - 1][n - 1];
11+
}

0 commit comments

Comments
 (0)