Challenge: Staircase Problem

Let's solve the triple step problem! Otherwise known as the staircase problem!

Problem Statement

A child is running up a staircase with n 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

int n = 4;

Sample Output

int result = 7;

Coding Exercise

Take a close look and design a step-by-step algorithm before jumping on 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 hint and solution provided in the code tab. Good Luck!

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.