From 8daae9c325a05bce1214b6f48ee6be43b6c1c4c3 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Mon, 1 Aug 2022 09:55:48 +0430 Subject: update --- 62/main.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 62/main.js (limited to '62') 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]; +}; -- cgit v1.2.3