Climbing Stairs
Easy
1-D Dynamic Programming
AmazonAdobe
You can climb 1 or 2 steps at a time. Given n steps, how many distinct ways can you reach the top?
Input: a single integer n.
Output: the number of ways.
Input: a single integer n.
Output: the number of ways.
Examples
Input:
5
Output:
8
Constraints
1 <= n <= 45
Sample test cases
Input
2
Expected output
2
Input
5
Expected output
8
Try solving it yourself first 💪
Write your solution in the editor, then hit “Mark solved”. In-browser run & auto-check is coming soon.