Minimum Jumps Required

How to solve this problem

A naive approach is to start from the first element and recursively call for all the elements reachable from first element. The minimum number of jumps to reach end from first can be calculated using minimum number of jumps needed to reach end from the elements reachable from first.

minJumps(start, end) = Min ( minJumps(k, end) ) for all k reachable from start

now try to do this using dp

 for (int i = n - 2; i >= 0; i--) { 
        if (i + arr[i] >= n - 1) { 
            int curr_res = minJumps(arr, i + 1); 
            if (curr_res != INT_MAX) 
                res = min(res, curr_res + 1); 
        } 
    }  

this is how recursive call happens

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.