leet-code/src/main/java/leetcode/editor/cn/ClimbingStairs.md

24 lines
847 B
Markdown
Raw Normal View History

2021-07-19 11:00:59 +08:00
<p>假设你正在爬楼梯。需要 <em>n</em>&nbsp;阶你才能到达楼顶。</p>
<p>每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?</p>
<p><strong>注意:</strong>给定 <em>n</em> 是一个正整数。</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong> 2
<strong>输出:</strong> 2
<strong>解释:</strong> 有两种方法可以爬到楼顶。
1. 1 阶 + 1 阶
2. 2 阶</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong> 3
<strong>输出:</strong> 3
<strong>解释:</strong> 有三种方法可以爬到楼顶。
1. 1 阶 + 1 阶 + 1 阶
2. 1 阶 + 2 阶
3. 2 阶 + 1 阶
</pre>
<div><div>Related Topics</div><div><li>记忆化搜索</li><li>数学</li><li>动态规划</li></div></div>\n<div><li>👍 1756</li><li>👎 0</li></div>