classSolution{publicintclimbStairs(int n){if( n ==1){return1;}int first =1;int second =2;for(int i =3; i <= n ;i++){int third = first + second;
first = second;
second = third;}return second;}}```
![在这里插入图片描述](https://img-blog.csdnimg.cn/1a5ebcde2a194a99a4174df6c8de42be.png)