plz help me in approaching this problem
Minimum Jumps Required
hello @Bhavya_Goel
logic is simple .
suppose u are at index i . and u know minimum steps to reach i (lets say st).also u can take jump of a[i] at max . so from i u can jump to i+1 , or i+2 ,i+3,i+4… i+a[i].
total steps required to reach any i+j(j can be 1 to a[i]) will be st+1. (st to reach i and 1 step to perform jump).
so if st+1 is less than the current min step to reach i+j then update min step.
code id - 230124 plz check i have implemented a recursive approach, how to change this into top down dp
see in this only s is a varying parameter so use 1 d array.
if dp[s]!=-1
return dp[s]
otherwise
do recursion and store at dp[s]
i have updated my code, plz check im getting the ans as 0
I have made some changes pls check
what all changes have you made, plz let me know my mistakes
just commented out dp[0] =0
because dp[0]=0 means to reach n-1 from 0 u need 0 steps which is clearly wrong.
bhaiya plz check at the time of submission some error is prompting for memset, plz see