Minimum number of jumps || Flipkart Series Part-3 || DSA || CODE || Interview Target
Given an array of N integers arr[] where each element represents the maximum length of the jump that can be made forward from that element. This means if arr[i] = x, then we can jump any distance y such that y ≤ x.
Find the minimum number of jumps to reach the end of the array (starting from the first element). If an element is 0, then you cannot move through that element.
Note: Return -1 if you can't reach the end of the array.
Example 1:
Input:
N = 11
arr[] = {1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9}
Output: 3
Explanation:
First jump from 1st element to 2nd
element with value 3. Now, from here
we jump to 5th element with value 9,
and from here we will jump to the last.
Question link:- https://www.geeksforgeeks.org/problem...
Follow Me On Social Media
Facebook:- / mdsaifraza.raza.526
LinkedIn:- linkedin.com/in/md-saif-raza-99941523a
Twitter:- / mdsaifr10053951
Instagram:- / saif_raza8544