|
1 | 1 | [#0070-climbing-stairs] |
2 | | -= 70. Climbing Stairs |
| 2 | += 70. 爬楼梯 |
3 | 3 |
|
4 | | -{leetcode}/problems/climbing-stairs/[LeetCode - Climbing Stairs^] |
| 4 | +https://leetcode.cn/problems/climbing-stairs/[LeetCode - 70. 爬楼梯^] |
5 | 5 |
|
6 | | -You are climbing a stair case. It takes _n_ steps to reach to the top. |
| 6 | +假设你正在爬楼梯。需要 `n` 阶你才能到达楼顶。 |
7 | 7 |
|
8 | | -Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? |
| 8 | +每次你可以爬 `1` 或 `2` 个台阶。你有多少种不同的方法可以爬到楼顶呢? |
9 | 9 |
|
10 | | -*Note:* Given _n_ will be a positive integer. |
| 10 | +*示例 1:* |
11 | 11 |
|
12 | | -*Example 1:* |
| 12 | +.... |
| 13 | +输入:n = 2 |
| 14 | +输出:2 |
| 15 | +解释:有两种方法可以爬到楼顶。 |
| 16 | +1. 1 阶 + 1 阶 |
| 17 | +2. 2 阶 |
| 18 | +.... |
13 | 19 |
|
14 | | -[subs="verbatim,quotes,macros"] |
15 | | ----- |
16 | | -*Input:* 2 |
17 | | -*Output:* 2 |
18 | | -*Explanation:* There are two ways to climb to the top. |
19 | | -1. 1 step + 1 step |
20 | | -2. 2 steps |
21 | | ----- |
| 20 | +*示例 2:* |
22 | 21 |
|
23 | | -*Example 2:* |
| 22 | +.... |
| 23 | +输入:n = 3 |
| 24 | +输出:3 |
| 25 | +解释:有三种方法可以爬到楼顶。 |
| 26 | +1. 1 阶 + 1 阶 + 1 阶 |
| 27 | +2. 1 阶 + 2 阶 |
| 28 | +3. 2 阶 + 1 阶 |
| 29 | +.... |
| 30 | + |
| 31 | +*提示:* |
| 32 | + |
| 33 | +* `+1 <= n <= 45+` |
24 | 34 |
|
25 | | -[subs="verbatim,quotes,macros"] |
26 | | ----- |
27 | | -*Input:* 3 |
28 | | -*Output:* 3 |
29 | | -*Explanation:* There are three ways to climb to the top. |
30 | | -1. 1 step + 1 step + 1 step |
31 | | -2. 1 step + 2 steps |
32 | | -3. 2 steps + 1 step |
33 | | ----- |
34 | 35 |
|
35 | 36 | == 思路分析 |
36 | 37 |
|
@@ -79,13 +80,22 @@ include::{sourcedir}/_0070_ClimbingStairs.java[tag=answer] |
79 | 80 | include::{sourcedir}/_0070_ClimbingStairs_2.java[tag=answer] |
80 | 81 | ---- |
81 | 82 | -- |
82 | | -==== |
83 | | - |
84 | | -== 参考资料 |
85 | 83 |
|
86 | | -. https://leetcode.cn/problems/climbing-stairs/solutions/2361764/70-pa-lou-ti-dong-tai-gui-hua-qing-xi-tu-ruwa/?envType=study-plan-v2&envId=selected-coding-interview[70. 爬楼梯 - 动态规划,清晰图解^] |
87 | | -. https://leetcode.cn/problems/climbing-stairs/solutions/286022/pa-lou-ti-by-leetcode-solution/?envType=study-plan-v2&envId=selected-coding-interview[70. 爬楼梯 - 官方题解^] |
88 | | -. https://leetcode.cn/problems/climbing-stairs/solutions/2560716/jiao-ni-yi-bu-bu-si-kao-dong-tai-gui-hua-7zm1/?envType=study-plan-v2&envId=selected-coding-interview[70. 爬楼梯 - 教你一步步思考动态规划:从记忆化搜索到递推^] |
| 84 | +三刷:: |
| 85 | ++ |
| 86 | +-- |
| 87 | +[{java_src_attr}] |
| 88 | +---- |
| 89 | +include::{sourcedir}/_0070_ClimbingStairs_3.java[tag=answer] |
| 90 | +---- |
| 91 | +-- |
| 92 | +==== |
89 | 93 |
|
90 | 94 |
|
| 95 | +== 参考资料 |
91 | 96 |
|
| 97 | +. https://leetcode.cn/problems/climbing-stairs/solutions/2560716/jiao-ni-yi-bu-bu-si-kao-dong-tai-gui-hua-7zm1/[70. 爬楼梯 - 教你一步步思考动态规划:从记忆化搜索到递推^] |
| 98 | +. https://leetcode.cn/problems/climbing-stairs/solutions/270926/cong-zhi-jue-si-wei-fen-xi-dong-tai-gui-hua-si-lu-/[70. 爬楼梯 - 「手画图解」详解爬楼梯问题 | 从递归,讲到动态规划^] |
| 99 | +. https://leetcode.cn/problems/climbing-stairs/solutions/854668/dai-ma-sui-xiang-lu-dong-tai-gui-hua-jin-y1hw/[70. 爬楼梯 - 「代码随想录」动态规划精讲!^] |
| 100 | +. https://leetcode.cn/problems/climbing-stairs/solutions/2361764/70-pa-lou-ti-dong-tai-gui-hua-qing-xi-tu-ruwa/[70. 爬楼梯 - 动态规划,清晰图解^] |
| 101 | +. https://leetcode.cn/problems/climbing-stairs/solutions/286022/pa-lou-ti-by-leetcode-solution/[70. 爬楼梯 - 官方题解^] |
0 commit comments