3341. Find Minimum Time to Reach Last Room I Medium
1/**
2 * [3341] Find Minimum Time to Reach Last Room I
3 *
4 * There is a dungeon with n x m rooms arranged as a grid.
5 * 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 exactly one second.
6 * Return the minimum time to reach the room (n - 1, m - 1).
7 * Two rooms are adjacent if they share a common wall, either horizontally or vertically.
8 *
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">moveTime = [[0,4],[4,4]]</span>
12 * Output: <span class="example-io">6</span>
13 * Explanation:
14 * The minimum time required is 6 seconds.
15 *
16 * At time t == 4, move from room (0, 0) to room (1, 0) in one second.
17 * At time t == 5, move from room (1, 0) to room (1, 1) in one second.
18 * </div>
19 * <strong class="example">Example 2:
20 * <div class="example-block">
21 * Input: <span class="example-io">moveTime = [[0,0,0],[0,0,0]]</span>
22 * Output: <span class="example-io">3</span>
23 * Explanation:
24 * The minimum time required is 3 seconds.
25 *
26 * At time t == 0, move from room (0, 0) to room (1, 0) in one second.
27 * At time t == 1, move from room (1, 0) to room (1, 1) in one second.
28 * At time t == 2, move from room (1, 1) to room (1, 2) in one second.
29 * </div>
30 * <strong class="example">Example 3:
31 * <div class="example-block">
32 * Input: <span class="example-io">moveTime = [[0,1],[1,2]]</span>
33 * Output: <span class="example-io">3</span>
34 * </div>
35 *
36 * Constraints:
37 *
38 * 2 <= n == moveTime.length <= 50
39 * 2 <= m == moveTime[i].length <= 50
40 * 0 <= moveTime[i][j] <= 10^9
41 *
42 */
43pub struct Solution {}
44
45// problem: https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/
46// discuss: https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/discuss/?currentPage=1&orderBy=most_votes&query=
47
48// submission codes start here
49
50impl Solution {
51 pub fn min_time_to_reach(move_time: Vec<Vec<i32>>) -> i32 {
52 0
53 }
54}
55
56// submission codes end
57
58#[cfg(test)]
59mod tests {
60 use super::*;
61
62 #[test]
63 fn test_3341() {
64 }
65}
66
Back
© 2025 bowen.ge All Rights Reserved.