Climbing Stairs
1D DP DSA practice problem on Onlearn.
Difficulty: medium.
Topics: How to write 1-D Recurrence relation / Climbing Stairs, Recursion, Dynamic Programming, Tabulation, Space Optimization, Time Complexity, Space Complexity, Fibonacci Series, dynamic programming, tabulation, recursion base case, space optimization, recursion, DP Techniques (Memoization & Tabulation), Recursive Function Components.
Climbing Stairs Problem Statement Given N stairs, starting from the 0th stair, you need to climb to the Nth stair. At a time, you can climb either one or two steps. Your task is to return the total number of distinct ways to reach from the 0th to the Nth stair. Input Specification The input will be a single integer N, representing the total number of stairs. Output Specification Return a single integer representing the total number of distinct ways to reach the Nth stair. Constraints 1 <= N <= 45 (Implied by typical competitive programming constraints for this problem and standard integer types) Sample Test Cases Sample Input 1 Sample Output 1 Explanation 1 To reach the 3rd stair: 1. 1 step + 1 step + 1 step 2. 1 step + 2 steps 3. 2 steps + 1 step There are 3 distinct ways. Difficulty Level Easy