From 423e707755975f1bafb335266d3aca45d6cd3d6e Mon Sep 17 00:00:00 2001 From: kayac-chang Date: Thu, 26 Aug 2021 13:23:55 +0800 Subject: [PATCH] add hello solution --- 2021-08/2021-08-26 (day39)/Hello/solution.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 2021-08/2021-08-26 (day39)/Hello/solution.js diff --git a/2021-08/2021-08-26 (day39)/Hello/solution.js b/2021-08/2021-08-26 (day39)/Hello/solution.js new file mode 100644 index 00000000..b1a80662 --- /dev/null +++ b/2021-08/2021-08-26 (day39)/Hello/solution.js @@ -0,0 +1,9 @@ +/** + * @param {number} n + * @return {number} + */ +function climbStairs(n, dp = [undefined, 1, 2]) { + dp[n] ||= climbStairs(n - 1, dp) + climbStairs(n - 2, dp); + + return dp[n]; +}