Skip to content

Instantly share code, notes, and snippets.

@prashantgpt91
Created October 3, 2017 04:20
Show Gist options
  • Save prashantgpt91/72368203e5117e07b355a784b7e00c5e to your computer and use it in GitHub Desktop.
Save prashantgpt91/72368203e5117e07b355a784b7e00c5e to your computer and use it in GitHub Desktop.
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