6. Climbing stairs
You climb a staircase of n steps, taking one or two steps at a time. Write climbStairs n, the number of different sequences of moves that reach the top.
There is one way to climb zero steps: do nothing. The hidden tests go up to 50 steps, and each check stops after about twelve seconds, so a solution that recomputes the same values over and over will run out of time.
Examples
- Input
climbStairs 2Output2 - Input
climbStairs 3Output3 - Input
climbStairs 5Output8
Submitting also runs 6 hidden tests.
Constraints
climbStairs 0 = 1andclimbStairs 1 = 1.- Hidden tests use
nup to 50.
Loading editor…
Type
\to in the editor, or click:Run checks your code against the examples and your custom inputs and records nothing. Submit also runs the hidden tests, confirms the axioms your proof uses and records the result. Each uses one compiler check.
ReadyLn 1, Col 1Lean 4
Draft saved in this browser