Reported July 2026
Zomatobreadth first search

Jump Game IV

Reported by candidates from Zomato's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Zomato OA. Under 2s to a working solution.
Founder's read

Zomato reported this one in July 2026, and it looks simple until the input gets big. Jump Game IV asks for the minimum jumps from index 0 to the last index, where you can step left, step right, or teleport to any index holding the same value. Naive neighbor scanning on every node blows up when the array is full of repeated values. This is a shortest-path-on-an-implicit-graph problem, so BFS is the move. If you blank on the grouping trick during the live OA, StealthCoder can sit invisibly on your screen as a safety net.

The problem

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[]) → int

Examples
Example 1
arr = [100,-23,-23,404,100,23,23,23,3,404]
return = 3
One shortest route is index 0 -> 4 -> 3 -> 9.
Example 2
arr = [7]
return = 0

Reported by candidates. Source: FastPrep

Pattern and pitfall

Treat each index as a node and each allowed jump as an unweighted edge. Minimum jumps means BFS. The trick is the value-to-indices map. Build a hash map from value to the list of indices holding it, then run BFS from index 0. When you pop an index, push i-1, i+1, and every index in its value group. The pitfall is that if you leave the group in the map, an array of all the same value makes you rescan that list at every node and you hit quadratic time. After you expand a value once, delete it from the map or clear its list. Every later visit is useless because BFS already reached them at the shortest distance. Also keep a visited set, and handle the single-element case by returning 0 immediately. If the clearing step slips your mind mid-assessment, StealthCoder is the hedge that surfaces it.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Jump Game IV cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Zomato's OA.

Zomato reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Jump Game IV FAQ

What's the trick in Jump Game IV?+

Group indices by value in a hash map and run BFS. The key optimization is clearing a value's index list after you first expand it. Without that, arrays with many duplicates make you rescan the same group repeatedly and time out.

Why BFS and not DP or DFS?+

Every jump costs one, so you want the fewest edges to the target in an unweighted graph. BFS gives that directly, level by level. DFS doesn't guarantee the shortest path, and DP has no clean ordering because jumps go both directions.

What input size breaks brute force here?+

Large arrays with lots of repeated values. If each node scans every matching index each time it's visited, the work grows toward n squared. The map plus clear-after-use step keeps total work near linear in the array length.

Is this graph pattern still asked in 2026 OAs?+

Zomato reported it in July 2026, so yes. Implicit-graph BFS shows up often because the graph is never given. You have to spot the nodes and edges yourself from the rules of movement.

How do I prep for this in 48 hours?+

Write the BFS once from scratch: queue, visited, value map, early return when you hit the last index. Then test it on [7] and on an all-same-value array. Those two cases catch the usual bugs, the edge case and the timeout.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Zomato.

OA at Zomato?
Invisible during screen share
Get it