-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rabbittee
committed
Aug 26, 2021
1 parent
38fe757
commit 56195d6
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# 70. Climbing Stairs | ||
|
||
`Easy` | ||
|
||
## Description | ||
|
||
<p>You are climbing a staircase. It takes <code>n</code> steps to reach the top.</p> | ||
|
||
<p>Each time you can either climb <code>1</code> or <code>2</code> steps. In how many distinct ways can you climb to the top?</p> | ||
|
||
<p> </p> | ||
<p><strong>Example 1:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 2 | ||
<strong>Output:</strong> 2 | ||
<strong>Explanation:</strong> There are two ways to climb to the top. | ||
1. 1 step + 1 step | ||
2. 2 steps | ||
</pre> | ||
|
||
<p><strong>Example 2:</strong></p> | ||
|
||
<pre> | ||
<strong>Input:</strong> n = 3 | ||
<strong>Output:</strong> 3 | ||
<strong>Explanation:</strong> There are three ways to climb to the top. | ||
1. 1 step + 1 step + 1 step | ||
2. 1 step + 2 steps | ||
3. 2 steps + 1 step | ||
</pre> | ||
|
||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
|
||
<ul> | ||
<li><code>1 <= n <= 45</code></li> | ||
</ul> | ||
|
||
|
||
--- | ||
|
||
### Topic Tags | ||
|
||
[math]: https://img.shields.io/badge/-Math-EF9A9A | ||
[dynamic-programming]: https://img.shields.io/badge/-Dynamic%20Programming-B39DDB | ||
[memoization]: https://img.shields.io/badge/-Memoization-81D4FA | ||
|
||
![Math][math] | ||
|
||
![Dynamic Programming][dynamic-programming] | ||
|
||
![Memoization][memoization] | ||
|
||
--- | ||
|
||
##### [original question](https://leetcode.com/problems/climbing-stairs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters