Skip to content

Instantly share code, notes, and snippets.

@prashantgpt91
Created October 3, 2017 04:19
Show Gist options
  • Save prashantgpt91/d29c24a4b832b3369d42a765893c59c8 to your computer and use it in GitHub Desktop.
Save prashantgpt91/d29c24a4b832b3369d42a765893c59c8 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
if(n==1)
return 1;
else if(n==2)
return 2;
else
return climbStairs(n-1) + climbStairs(n-2);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment