JZ9 跳台阶扩展问题

跳台阶扩展问题

https://www.nowcoder.com/practice/22243d016f6b47f2a6928b4313c85387?tpId=13&&tqId=11162&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking

public class Solution {
    public int jumpFloorII(int target) {
        return (int)Math.pow(2,target-1);
    }
}

f(n)=f(n-1)+f(n-2)+...+f(1)
f(n-1)=f(n-2)+...f(1)
得:f(n)=2f(n-1)=2^2f(n-2) = 2^(n-1)*1

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务