← problems
#70

Climbing Stairs

EasyDynamic Programming

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

Example

n = 2  => 2   // (1+1), (2)
n = 3  => 3   // (1+1+1), (1+2), (2+1)
Implement
function ClimbStairs(n: int) -> int

Found a bug? Or annoyed about something in the language? Tell us.

loading editor…