标签:
public class Solution { // 递归 类似斐波那契数列 /* public int JumpFloor(int target) { if(target<=1){ return 1; } if(target == 2){ return 2; } return JumpFloor(target-2)+JumpFloor(target-1); } */ // 动态规划 public int JumpFloor(int target){ if(target<=1){ return 1; } int last=1; int lastLast=1; int now=0; for(int i=2; i<=target; i++){ now = last + lastLast; lastLast = last; last = now; } return now; }
}
标签:
原文地址:http://www.cnblogs.com/hesier/p/5575840.html