Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

160. Climbing Stairs

EasyDay 47 of 60Dynamic Programming

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

Example 1
Input: n = 2
Output: 2
1 + 1 or 2.
Example 2
Input: n = 3
Output: 3
1 + 1 + 1, 1 + 2, or 2 + 1.
Constraints
  • 1 <= n <= 45
Hints
Frequently asked at: Amazon, Google, Adobe, TCS, Infosys
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min