Dsa
Dynamic Programming
Easy
Stair Climbing
You want to climb to the top of a staircase with `n` steps. You can take either 1 step or 2 steps at a time. Write a program to find the number of distinct ways to climb to the top.
Input format:
- A single integer `n` (1 ≤ n ≤ 50).
Output format:
- A single integer representing the number of distinct ways to reach the top.
Example:
Input:
4
Output:
5
Key concepts
dynamic_programmingcombinatoricsrecursion
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