https://leetcode.com/explore/interview/card/top-interview-questions-easy/97/dynamic-programming/569/
Explore - LeetCode
LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore.
leetcode.com
javascript
닫기/**
* @param {number} n
* @return {number}
*/
var climbStairs = function (n) {
const dp = new Map();
const Climbing = (n) => {
if ([1, 2].includes(n)) return n;
let n1 = parseInt(n - 1),
n2 = parseInt(n - 2);
if (!dp.has(n1)) dp.set(n1, Climbing(n1));
if (!dp.has(n2)) dp.set(n2, Climbing(n2));
return dp.get(n1) + dp.get(n2);
};
return Climbing(n);
};
GitHub : https://github.com/developeSHG/Algorithm-LeetCode/tree/main/climbing-stairs
GitHub - developeSHG/Algorithm-LeetCode: 릿코드 소스코드
릿코드 소스코드. Contribute to developeSHG/Algorithm-LeetCode development by creating an account on GitHub.
github.com
'Coding Test > LeetCode' 카테고리의 다른 글
[LeetCode] (Design) Lv Easy. Shuffle an Array (0) | 2023.01.25 |
---|---|
[LeetCode] (Math) Lv Easy. Fizz Buzz (0) | 2023.01.22 |
[LeetCode] (Sorting and Searching) Lv Easy. First Bad Version (0) | 2023.01.22 |
[LeetCode] (Sorting and Searching) Lv Easy. Merge Sorted Array (0) | 2023.01.22 |
[LeetCode] (Trees) Lv Easy. Maximum Depth of Binary Tree (0) | 2023.01.21 |
댓글