aboutsummaryrefslogtreecommitdiffstats
path: root/62
diff options
context:
space:
mode:
Diffstat (limited to '62')
-rw-r--r--62/main.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/62/main.js b/62/main.js
new file mode 100644
index 0000000..9222462
--- /dev/null
+++ b/62/main.js
@@ -0,0 +1,8 @@
+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];
+};