Package g0001_0100.s0070_climbing_stairs
Class Solution
java.lang.Object
g0001_0100.s0070_climbing_stairs.Solution
70 - Climbing Stairs.<p>Easy</p>
<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><strong>Example 1:</strong></p>
<p><strong>Input:</strong> n = 2</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> n = 3</p>
<p><strong>Output:</strong> 3</p>
<p><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</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= n <= 45</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
climbStairs
public int climbStairs(int n)
-