题解 | #跳台阶#
跳台阶
http://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
public class Solution {
public int jumpFloor(int target) {
int a = 1,b = 1,sum;
for (int i = 0; i < target; i++) { //循环遍历 利用转移方程依次向下计算f(n)的情况种类
sum = a+b;
a = b;
b = sum;
}
return a; //通过观察发现 循环i = n-1 时,此时a中存的数是想要求的结果
}
}