Climbing Stairs Problem

Climbing Stairs Problem — ExecCode Medium DSA Practice

Solve the Climbing Stairs problem on ExecCode. Free online medium DSA practice in DP. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You are climbing a staircase. It takes n steps to reach the top. Each time you can climb 1 or 2 steps. In how many distinct ways can you climb to the top?

Examples

Input n = 5; Output 8. Input n = 3; Output 3. Input n = 2; Output 2

Constraints

1 ≤ n ≤ 45

Practice Climbing Stairs free on ExecCode. Browse DSA problems, topic map, and placement guides.