题目描述

一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果)。

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

相关文章:

  • 2022-01-03
  • 2021-10-04
  • 2021-12-29
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-01
猜你喜欢
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2021-03-30
  • 2022-01-17
  • 2021-10-26
相关资源
相似解决方案