Skip to content

Commit a554bbd

Browse files
committed
climbing-stairs solutions
1 parent 861bfbc commit a554bbd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

climbing-stairs/dylan-jung.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
int dp[45] = { 0 };
3+
public:
4+
int climbStairs(int n) {
5+
dp[0] = 1;
6+
if(n > 1) dp[1] = 2;
7+
for(int i = 2; i < n; i++)
8+
dp[i] = dp[i-1] + dp[i-2];
9+
return dp[n-1];
10+
}
11+
};

0 commit comments

Comments
 (0)