Java
public class Solution {
public int climbStairs(int n) {
if(n==1) return 1;
if(n==2) return 2;
int result=0;
int tmp1=1;
int tmp2=2;
for(int i=2;i<n;i++)
{
result=tmp1+tmp2;
tmp1=tmp2;
tmp2=result;
}
return result;
}
}