Skip to content

Commit

Permalink
add kevin day 39
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinshu1995 authored and huibizhang committed Aug 26, 2021
1 parent 93dd3ff commit 76dff58
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions 2021-08/2021-08-26 (day39)/Kevin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Climbing Stairs
17 changes: 17 additions & 0 deletions 2021-08/2021-08-26 (day39)/Kevin/solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @param {number} n
* @return {number}
*/
var climbStairs = function(n) {
return helper(n, [])
};

function helper(n, cache){
if(cache[n]){
return cache[n]
}
if(n === 1) cache[n] = 1
else if(n === 2) cache[n] = 2
else cache[n] = helper(n-2, cache) + helper(n-1, cache)
return cache[n]
}

0 comments on commit 76dff58

Please sign in to comment.