Loading...
Loading...
Loading...
A robot climbs a staircase of n steps and can climb 1, 2 or 3 steps at a time. Count the different ways to reach the top. The count can be very large, so print it exactly.
Example 1
Input
4
Output
7
7 ways.
Example 2
Input
1
Output
1
Try the problem first. Open one hint at a time.
The ways to reach step k are the ways to reach k - 1, k - 2 and k - 3 added together.
Cache results so each step is solved once, or fill a list from the bottom.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor