Dsa
Dynamic Programming
Warm-up
Climbing Stairs
You are climbing a staircase with `n` steps. Each time you can either climb 1 or 2 steps. Write a function that returns how many distinct ways you can climb to the top.
Input format:
- A single integer, `n` (1 <= n <= 30).
Output format:
- A single integer, the number of distinct ways to reach step `n`.
Example:
Input:
5
Output:
8
Key concepts
dynamic_programmingcombinatorialpaths
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