Skip to content

3341. Find Minimum Time to Reach Last Room I #1654

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to determine the minimum time required to reach the last room of a dungeon grid starting from the top-left corner (0,0) at time 0. Each room has a minimum time requirement before you can start moving into it, and moving between adjacent rooms takes exactly one second.

Approach

The problem can be efficiently solved using Dijkstra's algorithm, which is typically used to find the shortest path in a graph with non-negative weights. In this context, each room is a node, and the edges between nodes represent the time required to move from one room to another. The key insight is to model the arrival time at each room as the distance in Dijkstra's algorithm, considering both the movement …

Replies: 1 comment 2 replies

Comment options

mah-shamim
May 7, 2025
Maintainer Author

You must be logged in to vote
2 replies
@kovatz
Comment options

kovatz May 7, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim May 7, 2025
Maintainer Author

Answer selected by kovatz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants