aboutsummaryrefslogtreecommitdiffstats
path: root/62
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2022-08-01 05:25:48 +0000
committerterminaldweller <thabogre@gmail.com>2022-08-01 05:25:48 +0000
commit8daae9c325a05bce1214b6f48ee6be43b6c1c4c3 (patch)
tree37f1b893de25d5b570fd7727d50f2040cf4c42e6 /62
parentupdate (diff)
downloadleetcode-8daae9c325a05bce1214b6f48ee6be43b6c1c4c3.tar.gz
leetcode-8daae9c325a05bce1214b6f48ee6be43b6c1c4c3.zip
update
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];
+};