Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 1.96 KB

File metadata and controls

29 lines (23 loc) · 1.96 KB

Climbing Stairs easy #javascript #blind75 #dynamic-programming

by Pawan Kumar @jsartisan

Take the Challenge

Given a staircase with n steps, find the number of distinct ways to climb to the top if you can:

  • Take 1 step at a time
  • Take 2 steps at a time

Constraints:

  • 1 ≤ n ≤ 30

Examples:

// Example 1:
console.log(climbStairs(2));
// Output: 2
// Explanation: Two ways to climb:
// 1. 1 step + 1 step
// 2. 2 steps

// Example 2:
console.log(climbStairs(3));
// Output: 3
// Explanation: Three ways to climb:
// 1. 1 step + 1 step + 1 step
// 2. 1 step + 2 steps
// 3. 2 steps + 1 step

Back Share your Solutions Check out Solutions