function climbStairs(n) { if(n <= 2){ return n } return climbStairs(n-1) + climbStairs(n-2) } function climbStairs(n) { let map = new Map() map.set(1,1) map.set(2,2) function climb(n){ if(map.has(n)){ return map.get(n) } let res = climb(n - 1) + climb(n - 2) map.set(n,res) return res } return climb(n) }