#3341

Find Minimum Time to Reach Last Room I

medium · 55.5% accepted · 541 likes · top 49%

array · graph theory · heap (priority queue) · matrix · shortest path

⊣ practice⊣ open on leetcode ↗

Description

There is a dungeon with n x m rooms arranged as a grid.

You are given a 2D array moveTime of size n x m, where moveTime[i][j] represents the minimum time in seconds after which the room opens and can be moved to. You start from the room (0, 0) at time t = 0 and can move to an adjacent room. Moving between adjacent rooms takes exactly one second.

Return the minimum time to reach the room (n - 1, m - 1).

Two rooms are adjacent if they share a common wall, either horizontally or vertically.

Solution