From 4f6cb1f3650239a427f1820245eb1522cdb4abb4 Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Wed, 28 Oct 2026 13:45:03 +0800 Subject: [PATCH] =?UTF-8?q?Update=2010.3=20=E8=B7=B3=E5=8F=B0=E9=98=B6.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。 --- notes/10.3 跳台阶.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/notes/10.3 跳台阶.md b/notes/10.3 跳台阶.md index 2072cb90..06c7433d 100644 --- a/notes/10.3 跳台阶.md +++ b/notes/10.3 跳台阶.md @@ -2,7 +2,7 @@ ## 题目链接 -[牛客网](https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4?tpId=13&tqId=11161&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) +[Leetcode](https://leetcode.cn/problems/qing-wa-tiao-tai-jie-wen-ti-lcof/) ## 题目描述 @@ -25,13 +25,13 @@

```java -public int JumpFloor(int n) { - if (n <= 2) - return n; - int pre2 = 1, pre1 = 2; +public int trainWays(int num) { + if (num <= 1) + return 1; + int pre2 = 1, pre1 = 1; int result = 0; - for (int i = 2; i < n; i++) { - result = pre2 + pre1; + for (int i = 2; i <= num; i++) { + result = (pre2 + pre1) % 1000000007; pre2 = pre1; pre1 = result; }