mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-30 07:33:45 +00:00
Update 10.3 跳台阶.md
题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。
This commit is contained in:
+7
-7
@@ -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 @@
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/508c6e52-9f93-44ed-b6b9-e69050e14807.jpg" width="350px"> </div><br>
|
||||
|
||||
```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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user