-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Labels
ccode in c languagecode in c languageduplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershacktoberfestthis repo is eligible for hacktoberfest 2021this repo is eligible for hacktoberfest 2021hacktoberfest-acceptedThis tag ensures that your PRs here will be countedThis tag ensures that your PRs here will be countedhelp wantedExtra attention is neededExtra attention is neededjavacode in java languagecode in java languagepythoncode in python languagecode in python languagequestionFurther information is requestedFurther information is requested
Description
Given an array of integers where each element represents the max number of steps that can be made forward from that element. Write a function to return the minimum number of jumps to reach the end of the array (starting from the first element). If an element is 0, they cannot move through that element. If the end isn’t reachable, return -1.
Examples:
Input: arr[] = {1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9}
Output: 3 (1-> 3 -> 8 -> 9)
Explanation: 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ccode in c languagecode in c languageduplicateThis issue or pull request already existsThis issue or pull request already existsenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershacktoberfestthis repo is eligible for hacktoberfest 2021this repo is eligible for hacktoberfest 2021hacktoberfest-acceptedThis tag ensures that your PRs here will be countedThis tag ensures that your PRs here will be countedhelp wantedExtra attention is neededExtra attention is neededjavacode in java languagecode in java languagepythoncode in python languagecode in python languagequestionFurther information is requestedFurther information is requested