You climb a staircase with n steps. Each move goes up 1 or 2 steps. Return the number of different ways to reach the top, modulo 10**9 + 7.
For n = 3 the answer is 3 (1+1+1, 1+2, 2+1).
The starter code is a plain recursion. It is correct but far too slow for large n.
Example 1
Input:
climb_stairs(3)
Output:
3
Example 2
Input:
climb_stairs(5)
Output:
8
0 <= n <= 1000000No results yet
Run your code to check it against the examples, or submit to run every test.