Skip to content

Instantly share code, notes, and snippets.

@yevmoroz
Created April 16, 2024 15:47
Show Gist options
  • Save yevmoroz/dab6479b70a09dfc8e7e3702434d6f69 to your computer and use it in GitHub Desktop.
Save yevmoroz/dab6479b70a09dfc8e7e3702434d6f69 to your computer and use it in GitHub Desktop.
leetcode unique paths mxn
/**
* @param {number} m
* @param {number} n
* @return {number}
*/
function uniquePaths(m, n) {
let arr = [];
for (let i = 0; i <=m; i++) {
arr.push(new Array(n + 1).fill(0));
}
arr[1][0] = 1;
for (let i = 1; i <=m; i++){
for(let j = 1; j<=n; j++){
arr[i][j] = arr[i - 1][j]+arr[i][j - 1];
}
}
return arr[m][n];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment