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; }