Update 10.4 变态跳台阶.md

代码块语言 source-java 改为 java,公式代码块标注语言。
This commit is contained in:
CyC2018
2026-10-25 19:03:37 +08:00
parent de082f747b
commit 8f3e9c268f
+5 -5
View File
@@ -29,31 +29,31 @@ public int jumpFloorII(int target) {
跳上 n-1 级台阶,可以从 n-2 级跳 1 级上去,也可以从 n-3 级跳 2 级上去...,那么
```
```text
f(n-1) = f(n-2) + f(n-3) + ... + f(0)
```
同样,跳上 n 级台阶,可以从 n-1 级跳 1 级上去,也可以从 n-2 级跳 2 级上去... ,那么
```
```text
f(n) = f(n-1) + f(n-2) + ... + f(0)
```
综上可得
```
```text
f(n) - f(n-1) = f(n-1)
```
即
```
```text
f(n) = 2*f(n-1)
```
所以 f(n) 是一个等比数列
```source-java
```java
public int JumpFloorII(int target) {
return (int) Math.pow(2, target - 1);
}