class Solution {
public int climbStairs(int n) {
int[] f = new int[n+1];
if(n == 1 || n==2) return n;
f[1] = 1;
f[2] = 2;
for(int i=3;i<=n;i++){
f[i] = f[i-1]+f[i-2];
}
return f[n];
}
}
70. 爬楼梯
最新推荐文章于 2024-08-16 23:08:36 发布