Dsa
Dynamic Programming
Easy
Climbing Stairs Variations
You are climbing a staircase with n steps. Each time you can either climb 1 or 2 steps. Write a program to find the number of distinct ways to reach the top of the staircase. Given n, write a function that computes the total number of different sequences of steps you could take.
Input format:
A single integer n (1 <= n <= 50), representing the number of steps.
Output format:
Print an integer representing the total number of distinct ways to climb to the top.
Example:
Input:
4
Output:
5
Key concepts
dynamic_programmingcombinatorics
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now