Facebook Pixel

Climbing Stairs

Problem Statement

You are climbing a staircase with n steps. Each time you can climb either 1 or 2 steps. Return the number of distinct ways to reach the top.

Examples

Example 1:
Input: n = 2
Output: 2
Explanation:

There are two ways: (1 step + 1 step) or (2 steps).

Example 2:
Input: n = 3
Output: 3
Explanation:

There are three ways: (1+1+1), (1+2), or (2+1).

Try it yourself

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro