Skip to content

Commit f67b65a

Browse files
committed
climbing chairs 풀이
1 parent 1f30af4 commit f67b65a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

climbing-stairs/haung921209.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```cpp
2+
class Solution {
3+
public:
4+
int climbStairs(int n) {
5+
vector<int> dp = {0, 1, 2};
6+
dp.resize(n+1);
7+
for(int i=3;i<=n;i++){
8+
dp[i] = dp[i-1] + dp[i-2];
9+
}
10+
return dp[n];
11+
}
12+
};
13+
```
14+
- O(n)
15+
- dp

0 commit comments

Comments
 (0)