K29
Climbing Stairs
Problem Statement & Objective
You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Function Signature (Python)
climbing_stairs(n: int) -> intInput & Output Contract
Output Rule:Farklı tırmanma yollarının sayısı (tam sayı).
System Constraints
1 <= n <= 45Example Execution Walkthrough
n = 2 -> 1+1, 2 -> 2 yol
n = 3 -> 1+1+1, 1+2, 2+1 -> 3 yolExample Test Scenarios (3)
Example 1
Input:
[2]Expected Output:
2Example 2
Input:
[3]Expected Output:
3Example 3: 5 Yol
Input:
[4]Expected Output:
5