题解 | #跳台阶#
跳台阶
http://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
自底向上求解 想象成到第几个台阶有几个方法 斐波那契数列
public class Solution {
public int jumpFloor(int target) {
if (target<=1) return 1;
int a =1,b=1,c=0;
for(int i=2;i<=target;i++){
c = a+b;
a = b;
b = c;
}
return c;
}
}
查看15道真题和解析