Challenge: The Staircase Problem
Solve the staircase problem, also known as the triple-step problem.
We'll cover the following
Problem statement
Suppose a child is running up a staircase with steps and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a function to count the number of possible ways that the child can run up the stairs.
Input
An integer that represents the number of stairs.
Output
An integer that represents the number of ways that those stairs can be climbed.
Sample input
n = 4;
Sample output
result = 7;
Coding challenge
First, take a close look at this problem and design a step-by-step algorithm before jumping to the implementation. This problem is designed for your practice, so try to solve it on your own first. If you get stuck, you can always refer to the solution provided in the solution section. Good luck!
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.