The Find Minimum Time to Reach Last Room I interview question is a pathfinding problem on a 2D grid. Each cell has a "move-in" time. You start at at time . You can move to an adjacent cell only if the current time is greater than or equal to that cell's required time. If you arrive early, you must wait until the cell "opens." Each move itself takes 1 second. You need to find the minimum time to reach the bottom-right corner.
Companies like Uber and Google use the Find Minimum Time to Reach Last Room coding problem to assess your knowledge of Shortest Path algorithms on a graph. It’s a twist on standard grid traversal because the "weight" of an edge is dynamic—it depends on your arrival time. It tests your ability to adapt Dijkstra's algorithm to handle waiting times.
This problem is solved using Dijkstra's Algorithm with a Priority Queue.
(time, row, col), always exploring the state with the minimum time first.currentTime:
max(currentTime, moveInTime[r2][c2]).max(currentTime, moveInTime[r2][c2]) + 1.minTime[row][col] matrix to avoid redundant explorations.Grid: [[0, 3], [3, 3]]
minTime array to prune paths that are already known to be sub-optimal.Master Dijkstra on grids. Practice problems where the "cost" of a move is not just a constant but a function of your current state. This is a common Matrix interview pattern for advanced roles.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Find Minimum Time to Reach Last Room II | Medium | Solve | |
| Find a Safe Walk Through a Grid | Medium | Solve | |
| Path with Maximum Probability | Medium | Solve | |
| Minimum Obstacle Removal to Reach Corner | Hard | Solve | |
| Minimum Cost of a Path With Special Roads | Medium | Solve |