From f5d902cdd5aea489eb0f552d8c816c382b11948d Mon Sep 17 00:00:00 2001 From: Omooo <869759698@qq.com> Date: Wed, 1 Jul 2020 08:54:06 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E9=80=92=E5=BD=92=E7=9B=B8=E5=85=B3.m?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blogs/Algorithm/剑指 Offer/递归相关.md | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/blogs/Algorithm/剑指 Offer/递归相关.md b/blogs/Algorithm/剑指 Offer/递归相关.md index fd711ab..a1787a6 100644 --- a/blogs/Algorithm/剑指 Offer/递归相关.md +++ b/blogs/Algorithm/剑指 Offer/递归相关.md @@ -24,3 +24,25 @@ class Solution { } ``` +#### [10- II. 青蛙跳台阶问题](https://leetcode-cn.com/problems/qing-wa-tiao-tai-jie-wen-ti-lcof/) + +```java +class Solution { + + public int numWays(int n) { + int result = 0; + int start = 1; + int end = 1; + if (n == 0 || n == 1) { + return 1; + } + for (int i = 2; i <= n; i++) { + result = (start + end) % 1000000007; + start = end; + end = result; + } + return result; + } +} +``` +