public class Solution {
public int climbStairs(int n) {
int
f1 = 2;
int f2 = 1;
if(n<=0) return 0;
if(n==1)
return f2;
if(n==2) return f1;
int fn=0;
for(int
i=2;i<n;i++){
fn=f1+f2;
f2=f1;
f1=fn;
}
return fn;
}
}
相关文章
- 12-21Climbing Stairs 解答
- 12-21Codeforces Round #394 (Div. 2) A. Dasha and Stairs 水题
- 12-21Cllimbing Stairs [LeetCode 70]
- 12-21[LeetCode] 746. Min Cost Climbing Stairs
- 12-21[leetcode]_Climbing Stairs
- 12-21LintCode 111 Climbing Stairs
- 12-2170. Climbing Stairs(easy, 号称 Dynamic Programming 天下第一题)
- 12-21climbing stairs(爬楼梯)(动态规划)
- 12-21[leetcode DP]70. Climbing Stairs
- 12-213月3日(6) Climbing Stairs