Month End Sale: Get Extra 10% OFF on Job-oriented Training! Offer Ending in
D
H
M
S
Get Now

Java: Minimum Number of Jumps to Reach End

Level : Beginner
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:20:00

Lab Details

Problem Statement:

Given an array arr[] where each element represents the max number of steps that can be made

forward from that index. The task is to find the minimum number of jumps to reach the end of

the array starting from index 0. If the end isn’t reachable, return -1.

Input:

arr[] = {1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9}

Output:

3 (1-> 3 -> 9 -> 9)
Jump from 1st element to 2nd element as there is only 1 step.
Now there are three options 5, 8 or 9. 

If 8 or 9 is chosen then the end node 9 can be reached. So, 3 jumps are made.

Self-paced Membership
  • 22+ Video Courses
  • 800+ Hands-On Labs
  • 400+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this