O(1) Solution :


#1

int Solution::climbStairs(int n) {
if(n==1)return 1;
double phi = (sqrt(5)+1)/2;
double n1 = (pow(phi,n-1)-pow(phi*(-1),(n-1)(-1)))/sqrt(5);
double n2 = (pow(phi,n)-pow(phi
(-1),(n)*(-1)))/sqrt(5);
return (int)(n1+n2);
}


#2

its an approximation formula, it wont work work large values of n!


#3

It is still not O(1). I think that the fastest way of calculating sqrt and pow is O(logn).