题解 | #删除链表的节点#

跳台阶

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

  1. target=1,res=1;
  2. target=2,res=2;
  3. target=3,res=3;
  4. target=4,res=5;
  5. 递推公式为 res(n)=res(n-1)+res(n-2);
public class Solution {
    public int jumpFloor(int target) {
        if(target==1){
            return 1;
        }
        if(target==2){
            return 2;
        }else{
            return (int) jumpFloor(target-1)+jumpFloor(target-2);
        }
    }
}
全部评论

相关推荐

迷茫的大四🐶:干脆大厂搞个收费培训得了,这样就人均大厂了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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