Codevita Question Doubt

Here is the question statement.

Given an integer n which is the number of steps from first floor to ground floor in a building. We can either move 1 step down, or 2 step down, or 3 step down. However, we may move 3 steps down at most once. In other words, a 3 step move can be done any time but only once. We have to find the number of ways to reach the ground floor.

Can anyone help me how to solve this problem?

I have done something like this:
f(n,k) denote the number of ways you can get to ground floor from the n-th step, going three steps at once exactly k times.
f(n,k)=f(n−1,k)+f(n−2,k)+f(n−3,k−1)
Here , in question for us k = 1.

But i am not able to implement it well.
Anyone can help?

Thank you :slightly_smiling_face:

1 Like

Was that a codevita question??