Skip to content

Commit 6f35c59

Browse files
committed
update gitignore
1 parent 385e40b commit 6f35c59

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

.DS_Store

-6 KB
Binary file not shown.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea
2+
.DS_Store

Doc/变态跳台阶.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# 变态跳台阶
2+
3+
4+
## 题目描述
5+
一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。
6+
7+
8+
## 解题思路
9+
10+
设共有m种不同跳法
11+
12+
- 如果n=1,那么m=1
13+
- 如果n=2,那么m=2
14+
15+
对于n阶台阶:
16+
17+
- case1:第一次跳了1个台阶,就有f(n-1)种跳法
18+
- case2:第一次挑个2个台阶,就有f(n-2)种跳法
19+
20+
所以总的n阶台阶的跳法f(n)=case1+case2=f(n-1)+f(n-2)
21+
22+
这是典型的斐波那契数列,需要注意的是尽量不要用递归去求解斐波那契数列,尽量使用循环,如果只需要第n项,不用保存所有n项数据,只需每次保存前2项即可。
23+
24+
25+
## 代码
26+
27+
[这里](../Code/8.py)

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
- [用两个栈实现队列](./Doc/用两个栈实现队列.md)
88
- [旋转数组的最小数字](./Doc/旋转数组的最小数字.md)
99
- [跳台阶](./Doc/跳台阶.md)
10+
- [变态跳台阶](./Doc/变态跳台阶.md)

0 commit comments

Comments
 (0)