14 } 15 }考虑时间效率,采用动态规划进行优化 public class Solution { public int JumpFloor(int target) { if(target<3){ return target ; } int temp1 = 1 ,temp2 = 2 ; int res=0 ; for(int i = 3 ;i <= target ;i++){ res = temp1+temp2 ; temp1 = temp2 ; temp2 = res ; } return res ; } }
写这个系列主要时因为最近找工作在刷算法。把自己的结果分享出来给大家,也方便自己以后温习。
转载于:https://www.cnblogs.com/huntertoung/p/4753423.html