Recursive se soln Aya but not with dp .check this https://ide.codingblocks.com/s/681658
Minimum Jumps Requried
@arpitranjan641_d2edeaf633b10b54 first of all remove all the SysO except for the answer and benchmark your function with my function :
int minJumps(int arr[], int n)
{
// Base case: when source and
// destination are same
if (n == 1)
return 0;
// Traverse through all the points
// reachable from arr[l]
// Recursivel, get the minimum number
// of jumps needed to reach arr[h] from
// these reachable points
int res = INT_MAX;
for (int i = n - 2; i >= 0; i--) {
if (i + arr[i] >= n - 1) {
int sub_res = minJumps(arr, i + 1);
if (sub_res != INT_MAX)
res = min(res, sub_res + 1);
}
}
return res;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.