Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

class Solution { public: int climbStairs(int n) { int DP[n+1]; DP[1] = 1; DP[2] = 2; int i; for(i=3; i<=n; i++) DP[i] = DP[i-2] + DP[i-1]; return DP[n]; } };

class Solution { public: int climbStairs(int n) { if (n<=1) return n; int *memo = new int[n+1]; memo[0] = 1; memo[1] = 1; for(int i = 2; i<=n;i++){ memo[i] = memo[i-1]+ memo[i-2]; } return memo[n-1]+memo[n-2]; } };

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.