青蛙跳台阶

一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法

public class Solution {
    public int JumpFloor(int target) {
        if (target == 0) {
            return 0;
        }
        if (target == 1) {
            return 1;
        }
        return JumpFloor(target - 2) + JumpFloor(target - 1);
    }
}

态跳台阶 --- 一次可以跳1,2,3,,,n阶台阶

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

猜你喜欢

转载自blog.csdn.net/quitozang/article/details/80456505