Minimum Time to Visit a Cell In a Grid
A hard-tier problem at 57% community acceptance, tagged with Array, Breadth-First Search, Graph. Reported in interviews at Atlassian and 0 others.
Minimum Time to Visit a Cell In a Grid is a hard-rated shortest path problem that looks simple on first read but has a brutal trick that catches most candidates. You're moving through a matrix where each cell has a time cost, and you need to reach the destination in minimum time. The acceptance rate sits at 57%, which means nearly half the people submitting fail. Atlassian has asked this. Most candidates jump to Dijkstra's algorithm and get stuck when their greedy approach doesn't account for the timing constraint that makes certain moves impossible. If this problem hits your live assessment and you can't spot the pattern, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Minimum Time to Visit a Cell In a Grid"
Minimum Time to Visit a Cell In a Grid is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.
Get StealthCoderThe critical insight is that you can't always move to an adjacent cell even if it's on the shortest path graph. You can only visit a cell at time T if at least one of your neighbors is already visited at time T minus one or T minus two (since movement costs 1 unit minimum). This timing constraint transforms the problem from pure shortest-path into a state-space search where you track both position and arrival time. Dijkstra's algorithm handles this correctly because it processes states in order of increasing time, but you must check the arrival time precondition before relaxing edges. The naive greedy approach fails because it ignores this temporal dependency. Use a min-heap priority queue ordered by time, track visited states as (row, col, time) tuples, and verify that your current arrival time makes the next move legal before adding it. StealthCoder is the hedge if you freeze on the precondition check during the live OA.
Pattern tags
You know the problem.
Make sure you actually pass it.
Minimum Time to Visit a Cell In a Grid recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Time to Visit a Cell In a Grid interview FAQ
Why doesn't my Dijkstra solution work on the examples?+
You're likely not checking the arrival-time precondition. You can only reach a cell if the arrival time is exactly one or two time units after a neighbor was visited. This isn't standard shortest path. Add a guard clause before adding neighbors to the heap: verify that your arrival time is valid given when you last visited a neighbor.
Is this really asked at Atlassian, or only in rounds?+
Atlassian data shows it in their interview reports. The exact context (first phone screen, take-home, on-site) isn't specified in available job descriptions, but it's confirmed as part of their assessment pool.
How do I know when an obvious greedy approach will fail?+
Test on a small grid where the shortest path in terms of cell count looks like it should work, but the timing constraint makes certain cells unreachable. Greedy edge relaxation ignores time dependencies. If the problem explicitly constrains when you can arrive somewhere, Dijkstra with state validation beats greedy every time.
Should I use BFS or priority queue for this?+
Priority queue (Dijkstra). BFS assumes uniform edge weights, but cells have non-uniform arrival-time costs. BFS will explore states in the wrong order and miss the optimal solution. Min-heap by time guarantees you process earlier arrivals first, which respects the timing precondition.
What's the space complexity concern here?+
The state space is O(rows * cols * max_time). If your grid is large and timing values are unbounded, you can run out of memory or hit time limits. Track visited (row, col, time) tuples carefully and prune aggressively. Some optimal solutions cache only (row, col) with the minimum time seen, not every time value.
Want the actual problem statement? View "Minimum Time to Visit a Cell In a Grid" on LeetCode →