Skip to content

3342. Find Minimum Time to Reach Last Room II #1658

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

You must be logged in to vote

We need to find the minimum time required to reach the last room in a grid-based dungeon where each move alternates between taking 1 second and 2 seconds. Additionally, each room has a minimum time before you can start moving into it. The solution involves using a modified Dijkstra's algorithm to handle the alternating move times and the minimum start times for each room.

Approach

  1. Graph Representation: Treat the grid as a graph where each cell is a node, and edges exist between adjacent cells. The movement between nodes alternates between 1 and 2 seconds based on the number of moves made so far.
  2. State Tracking: Track the state of each node using both its position and the parity (even or …

Replies: 1 comment 2 replies

Comment options

mah-shamim
May 8, 2025
Maintainer Author

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

topugit May 8, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim May 8, 2025
Maintainer Author

Answer selected by topugit
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