070_爬楼梯
小于 1 分钟
070_爬楼梯简单
class Solution {
public int climbStairs(int n) {
if(n == 1){
return 1;
}
if(n == 2){
return 2;
}
int[] num = new int[n];
num[0] = 1;
num[1] = 2;
for(int i = 2;i < n;i++){
num[i] = num[i-1] + num[i-2];
}
return num[n-1];
}
}
Powered by Waline v2.15.5