|
| 1 | +3342\. Find Minimum Time to Reach Last Room II |
| 2 | + |
| 3 | +Medium |
| 4 | + |
| 5 | +There is a dungeon with `n x m` rooms arranged as a grid. |
| 6 | + |
| 7 | +You are given a 2D array `moveTime` of size `n x m`, where `moveTime[i][j]` represents the **minimum** time in seconds when you can **start moving** to that room. You start from the room `(0, 0)` at time `t = 0` and can move to an **adjacent** room. Moving between **adjacent** rooms takes one second for one move and two seconds for the next, **alternating** between the two. |
| 8 | + |
| 9 | +Return the **minimum** time to reach the room `(n - 1, m - 1)`. |
| 10 | + |
| 11 | +Two rooms are **adjacent** if they share a common wall, either _horizontally_ or _vertically_. |
| 12 | + |
| 13 | +**Example 1:** |
| 14 | + |
| 15 | +**Input:** moveTime = [[0,4],[4,4]] |
| 16 | + |
| 17 | +**Output:** 7 |
| 18 | + |
| 19 | +**Explanation:** |
| 20 | + |
| 21 | +The minimum time required is 7 seconds. |
| 22 | + |
| 23 | +* At time `t == 4`, move from room `(0, 0)` to room `(1, 0)` in one second. |
| 24 | +* At time `t == 5`, move from room `(1, 0)` to room `(1, 1)` in two seconds. |
| 25 | + |
| 26 | +**Example 2:** |
| 27 | + |
| 28 | +**Input:** moveTime = [[0,0,0,0],[0,0,0,0]] |
| 29 | + |
| 30 | +**Output:** 6 |
| 31 | + |
| 32 | +**Explanation:** |
| 33 | + |
| 34 | +The minimum time required is 6 seconds. |
| 35 | + |
| 36 | +* At time `t == 0`, move from room `(0, 0)` to room `(1, 0)` in one second. |
| 37 | +* At time `t == 1`, move from room `(1, 0)` to room `(1, 1)` in two seconds. |
| 38 | +* At time `t == 3`, move from room `(1, 1)` to room `(1, 2)` in one second. |
| 39 | +* At time `t == 4`, move from room `(1, 2)` to room `(1, 3)` in two seconds. |
| 40 | + |
| 41 | +**Example 3:** |
| 42 | + |
| 43 | +**Input:** moveTime = [[0,1],[1,2]] |
| 44 | + |
| 45 | +**Output:** 4 |
| 46 | + |
| 47 | +**Constraints:** |
| 48 | + |
| 49 | +* `2 <= n == moveTime.length <= 750` |
| 50 | +* `2 <= m == moveTime[i].length <= 750` |
| 51 | +* <code>0 <= moveTime[i][j] <= 10<sup>9</sup></code> |
0 commit comments