Submissions disabled: This deployment is running in read-only mode for safety. Code execution is not available here.
← Back to all problems
Easy

Climbing Stairs

Updated Jan 31, 2026

Problem

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?

Constraints

1 <= n <= 45

Examples

Example 1

Input: n = 2
Output: 2
There are two ways to climb to the top: 1. 1 step + 1 step, 2. 2 steps

Example 2

Input: n = 3
Output: 3
There are three ways: 1. 1+1+1, 2. 1+2, 3. 2+1

Function Signature

def climbStairs(self, n: int) -> int

How to Submit

Implement a Solution class with a climbStairs method.

Your method will be called with the input parameters and should return the answer.