题解 | #跳台阶#

跳台阶

http://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4

public class Solution {
    
    /*
    n    跳法
    1    1
    2    2
    3    3
    4    5
    5    8
    
    n    前两个跳法的和
    */
    public int jumpFloor(int target) {
        ArrayList<Integer> outCome = new ArrayList<>();
        
        outCome.add(0,1);
        outCome.add(1,2);
        if(target == 0 || target ==1){
            return outCome.get(target-1);
        }else{
            for(int i =2; i < target; i++){
                outCome.add(i, outCome.get(i-1) + outCome.get(i-2));
            }
            return outCome.get(target -1);
        }
    }
}
全部评论

相关推荐

点赞 评论 收藏
分享
06-13 10:15
门头沟学院 Java
想去夏威夷的大西瓜在...:我也是27届,但是我现在研一下了啥项目都没有呀咋办,哎,简历不知道咋写
点赞 评论 收藏
分享
找到实习了&nbsp;给了150一天&nbsp;但是说是低代码&nbsp;值得去吗
码农索隆:是在没实习,可去,待个一两周,不行就润呗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务