变态跳台阶java实现

xiaoxiao2021-02-28  146

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

青蛙跳上一个台阶有一种跳法,跳上两个台阶有两种跳法,跳上三个台阶有四种跳法,……,跳上n个台阶有2^(n-1)种跳法。

public class Solution { public int JumpFloorII(int target) { return (int)Math.pow(2, target-1); } }
转载请注明原文地址: https://www.6miu.com/read-26412.html

最新回复(0)