算法练习(25) leetcode 70. 爬楼梯

tech2025-11-09  7

https://leetcode-cn.com/problems/climbing-stairs/

class Solution { public int climbStairs(int n) { int x=1,y=2,t=0; if (n==1){ return 1; } if (n==2){ return 2; } for (int i=2;i<n;i++) { t=x+y; x=y; y=t; } return t; } }

 

最新回复(0)