3342. Find Minimum Time to Reach Last Room II Medium

@problem@discussion
#Array#Graph#Heap (Priority Queue)#Matrix#Shortest Path



1/**
2 * [3342] Find Minimum Time to Reach Last Room II
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 one second for one move and two seconds for the next, alternating between the two.
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: 7
13 * Explanation:
14 * The minimum time required is 7 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 two seconds.
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,0,0]]</span>
22 * Output: 6
23 * Explanation:
24 * The minimum time required is 6 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 two seconds.
28 * 	At time t == 3, move from room (1, 1) to room (1, 2) in one second.
29 * 	At time t == 4, move from room (1, 2) to room (1, 3) in two seconds.
30 * </div>
31 * <strong class="example">Example 3:
32 * <div class="example-block">
33 * Input: <span class="example-io">moveTime = [[0,1],[1,2]]</span>
34 * Output: 4
35 * </div>
36 *  
37 * Constraints:
38 * 
39 * 	2 <= n == moveTime.length <= 750
40 * 	2 <= m == moveTime[i].length <= 750
41 * 	0 <= moveTime[i][j] <= 10^9
42 * 
43 */
44pub struct Solution {}
45
46// problem: https://leetcode.com/problems/find-minimum-time-to-reach-last-room-ii/
47// discuss: https://leetcode.com/problems/find-minimum-time-to-reach-last-room-ii/discuss/?currentPage=1&orderBy=most_votes&query=
48
49// submission codes start here
50
51impl Solution {
52    pub fn min_time_to_reach(move_time: Vec<Vec<i32>>) -> i32 {
53        0
54    }
55}
56
57// submission codes end
58
59#[cfg(test)]
60mod tests {
61    use super::*;
62
63    #[test]
64    fn test_3342() {
65    }
66}
67


Back
© 2025 bowen.ge All Rights Reserved.