Jump Game IV
Updated
Problem statement
Given an integer array arr, start at index 0. From index i, one jump may move to i - 1, i + 1, or any index j such that arr[i] == arr[j].
Return the minimum number of jumps needed to reach the last index. Indices outside the array are not valid destinations.
Function
minJumps(arr: int[]) → intExamples
Example 1
arr = [100,-23,-23,404,100,23,23,23,3,404]return = 3One shortest route is index 0 -> 4 -> 3 -> 9.
Example 2
arr = [7]return = 0Source note: Source images are source-neutral excerpts of author-reported interview prompts.
More Zomato / Eternal interview questions
- Find the Two Unique NumbersONSITE INTERVIEW · Seen Oct 2026
- Flipping MatrixONSITE INTERVIEW · Seen Oct 2026
- LFU CacheONSITE INTERVIEW · Seen Aug 2026
- Special KeyboardONSITE INTERVIEW · Seen Jul 2026
- Detonate the Maximum BombsPHONE SCREEN · Seen Dec 2026
- Friend Circles and Redundant ConnectionsPHONE SCREEN · Seen Sep 2026
- Maximum Production Within PowerOA · Seen Jul 2026
- Rearrange Songs by AuthorOA · Seen Jul 2026
- Robot Warehouse OptimizationOA · Seen Jul 2026
Similar questions at other companies
- Largest Island After One FlipOracle · ONSITE INTERVIEWOracle interview questions
- Bus RoutesBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Shortest Path Through Numbers Sharing a DigitGoogle · PHONE SCREENGoogle interview questions
- Fewest Buses with the Full RouteMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Minimum Bus Routes to a DestinationPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
- Find Duplicate Files in a FilesystemHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
- Find All People With SecretIDFC Bank · ONSITE INTERVIEWIDFC Bank interview questions
- Word LadderGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- Word Ladder II: All Shortest TransformationsPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions