|
| 1 | +<p>There is a dungeon with <code>n x m</code> rooms arranged as a grid.</p> |
| 2 | + |
| 3 | +<p>You are given a 2D array <code>moveTime</code> of size <code>n x m</code>, where <code>moveTime[i][j]</code> represents the <strong>minimum</strong> time in seconds when you can <strong>start moving</strong> to that room. You start from the room <code>(0, 0)</code> at time <code>t = 0</code> and can move to an <strong>adjacent</strong> room. Moving between adjacent rooms takes <em>exactly</em> one second.</p> |
| 4 | + |
| 5 | +<p>Return the <strong>minimum</strong> time to reach the room <code>(n - 1, m - 1)</code>.</p> |
| 6 | + |
| 7 | +<p>Two rooms are <strong>adjacent</strong> if they share a common wall, either <em>horizontally</em> or <em>vertically</em>.</p> |
| 8 | + |
| 9 | +<p> </p> |
| 10 | +<p><strong class="example">Example 1:</strong></p> |
| 11 | + |
| 12 | +<div class="example-block"> |
| 13 | +<p><strong>Input:</strong> <span class="example-io">moveTime = [[0,4],[4,4]]</span></p> |
| 14 | + |
| 15 | +<p><strong>Output:</strong> <span class="example-io">6</span></p> |
| 16 | + |
| 17 | +<p><strong>Explanation:</strong></p> |
| 18 | + |
| 19 | +<p>The minimum time required is 6 seconds.</p> |
| 20 | + |
| 21 | +<ul> |
| 22 | + <li>At time <code>t == 4</code>, move from room <code>(0, 0)</code> to room <code>(1, 0)</code> in one second.</li> |
| 23 | + <li>At time <code>t == 5</code>, move from room <code>(1, 0)</code> to room <code>(1, 1)</code> in one second.</li> |
| 24 | +</ul> |
| 25 | +</div> |
| 26 | + |
| 27 | +<p><strong class="example">Example 2:</strong></p> |
| 28 | + |
| 29 | +<div class="example-block"> |
| 30 | +<p><strong>Input:</strong> <span class="example-io">moveTime = [[0,0,0],[0,0,0]]</span></p> |
| 31 | + |
| 32 | +<p><strong>Output:</strong> <span class="example-io">3</span></p> |
| 33 | + |
| 34 | +<p><strong>Explanation:</strong></p> |
| 35 | + |
| 36 | +<p>The minimum time required is 3 seconds.</p> |
| 37 | + |
| 38 | +<ul> |
| 39 | + <li>At time <code>t == 0</code>, move from room <code>(0, 0)</code> to room <code>(1, 0)</code> in one second.</li> |
| 40 | + <li>At time <code>t == 1</code>, move from room <code>(1, 0)</code> to room <code>(1, 1)</code> in one second.</li> |
| 41 | + <li>At time <code>t == 2</code>, move from room <code>(1, 1)</code> to room <code>(1, 2)</code> in one second.</li> |
| 42 | +</ul> |
| 43 | +</div> |
| 44 | + |
| 45 | +<p><strong class="example">Example 3:</strong></p> |
| 46 | + |
| 47 | +<div class="example-block"> |
| 48 | +<p><strong>Input:</strong> <span class="example-io">moveTime = [[0,1],[1,2]]</span></p> |
| 49 | + |
| 50 | +<p><strong>Output:</strong> <span class="example-io">3</span></p> |
| 51 | +</div> |
| 52 | + |
| 53 | +<p> </p> |
| 54 | +<p><strong>Constraints:</strong></p> |
| 55 | + |
| 56 | +<ul> |
| 57 | + <li><code>2 <= n == moveTime.length <= 50</code></li> |
| 58 | + <li><code>2 <= m == moveTime[i].length <= 50</code></li> |
| 59 | + <li><code>0 <= moveTime[i][j] <= 10<sup>9</sup></code></li> |
| 60 | +</ul> |
0 commit comments