class Solution {
public:
int climbStairs(int n) {
if (aux[n] == 0) {
if (n == 0  n == 1) aux[n] = 1;
else aux[n] = climbStairs(n1) + climbStairs(n2);
}
return aux[n];
}
private:
int aux[10000] = {0};
};
My Solution, is there any better solution?

I think you can change the recursively call. below is my python solution.
class Solution: # @param n, an integer # @return an integer def climbStairs(self, n): if n < 2: return 1 ways = [0] * (n+1) ways[0] = 0 ways[1] = 1 ways[2] = 2 for i in range(3, n+1): ways[i] = ways[i2] + ways[i1] return ways[n]

I have other idea we can use constant memory like upload guy said. below is my new solution.after modify.
class Solution: # @param n, an integer # @return an integer def climbStairs(self, n): if n == 1: return 1 if n == 2: return 2 first = 1 second = 2 for i in range(n2): first, second = second, second + first return second