diff options
author | terminaldweller <thabogre@gmail.com> | 2022-08-01 05:25:48 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2022-08-01 05:25:48 +0000 |
commit | 8daae9c325a05bce1214b6f48ee6be43b6c1c4c3 (patch) | |
tree | 37f1b893de25d5b570fd7727d50f2040cf4c42e6 | |
parent | update (diff) | |
download | leetcode-8daae9c325a05bce1214b6f48ee6be43b6c1c4c3.tar.gz leetcode-8daae9c325a05bce1214b6f48ee6be43b6c1c4c3.zip |
update
-rw-r--r-- | 62/main.js | 8 |
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]; +}; |