blob: 922246209edaf91a51d1b3d45dff56629a7c0f79 (
plain) (
tree)
|
|
var uniquePaths = function (m, n, memo = {}) {
const key = m + "," + n;
if (key in memo) return memo[key];
if (m === 1 && n === 1) return 1;
if (m === 0 || n === 0) return 0;
memo[key] = uniquePaths(m - 1, n, memo) + uniquePaths(m, n - 1, memo);
return memo[key];
};
|