Given an array of positive numbers, where each element represents the max number of jumps that can be made forward from that element, write a program to find the minimum number of jumps needed to reach the end of the array (starting from the first element). If an element is 0, then we cannot move through that element.

package practice;

public class ArrayJump {

public int countMinJumps(int[] jumps) {

if (jumps == null || jumps.length < 2) {
return 0;
}
int[] minJumps = new int[jumps.length];
minJumps[0] = 0;

Reference Video: https://www.youtube.com/watch?v=cETfFsSTGJI

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store