File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ <h2 >70. Climbing Stairs</h2 ><h3 >Easy</h3 ><hr ><div ><p >You are climbing a staircase. It takes <code >n</code > steps to reach the top.</p >
2
+
3
+ <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 >
4
+
5
+ <p >  ; </p >
6
+ <p ><strong >Example 1:</strong ></p >
7
+
8
+ <pre ><strong >Input:</strong > n = 2
9
+ <strong >Output:</strong > 2
10
+ <strong >Explanation:</strong > There are two ways to climb to the top.
11
+ 1. 1 step + 1 step
12
+ 2. 2 steps
13
+ </pre >
14
+
15
+ <p ><strong >Example 2:</strong ></p >
16
+
17
+ <pre ><strong >Input:</strong > n = 3
18
+ <strong >Output:</strong > 3
19
+ <strong >Explanation:</strong > There are three ways to climb to the top.
20
+ 1. 1 step + 1 step + 1 step
21
+ 2. 1 step + 2 steps
22
+ 3. 2 steps + 1 step
23
+ </pre >
24
+
25
+ <p >  ; </p >
26
+ <p ><strong >Constraints:</strong ></p >
27
+
28
+ <ul >
29
+ <li><code>1 <= n <= 45</code></li>
30
+ </ul >
31
+ </div >
You can’t perform that action at this time.
0 commit comments