In NK Ladder Problem, where we need to find no of ways to get to nth step by taking 1,2,…k steps.
In Simple Recursion- Recursive case = return F(n-1) + F(n-2) + … + F(n-k) having Base Case- if(n < 0) return 0 and if(n == 0) return 1.
This worked fine, but in video, prateek bhaiya told about more efficient way in which linear recurrence function is reduced to- F(n) = 2*F(n-1) + F(n-(k+1)). But, when implemented using Recursion, it’ll not give right ans. How to use this function for efficient code???