Created
October 3, 2017 04:20
-
-
Save prashantgpt91/72368203e5117e07b355a784b7e00c5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public: | |
/** | |
* @param n: An integer | |
* @return: An integer | |
*/ | |
int climbStairs(int n) { | |
// write your code here | |
int dp[n+1]; | |
dp[0] = 0; | |
dp[1] = 1; | |
dp[2] = 2; | |
for(int i=3;i<=n;i++) | |
dp[i] = dp[i-1] + dp[i-2]; | |
return dp[n]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment