Modified problem

What will be soln if steps allowed were 1, 2, 4. and n = 5 ?

hello @anuj_it
then also approach remains same.
dp[0]=1.

dp[i] = dp[i-1]+dp[i-2]+dp[i-4]. // i from 1 to n.