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.
I thought the solution is simply:
$f[n] = f[n-1]+f[n-2]+f[n-3]$
However, I am not getting the right answer. What could be possibly wrong?
Let $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.
Then the recurrence you get is $$f(n,k) = f(n-1,k) + f(n-2,k) + f(n-3,k-1)$$
with appropiate initial values, and the answer you're looking for is $f(10,0) + f(10,1)$.