Tap here to switch tabs
Problem
Submissions

Problem: Find Minimum Time to Reach Last Room I

Try to solve the Find Minimum Time to Reach Last Room I problem.

Statement

You are given a 2D2 {D} integer array moveTime of size n×mn \times m, where moveTime[i][j] represents the minimum time in seconds that must elapse before you can start moving into room (i,j)(i, j).

You begin at room (0,0)(0, 0) at time t=0t = 0. From any room, you can move to any adjacent room sharing an edge in the four cardinal directions (up, down, left, right). Each move between adjacent rooms takes exactly 11 second. You can only start moving toward a room (i,j)(i, j) once the current time is greater than or equal to moveTime[i][j].

Return the minimum time in seconds required to reach the destination room (n−1,m−1)(n - 1, m - 1).

Constraints:

  • 2≤n==2 \leq n == moveTime.length ≤50\leq 50

  • 2≤m==2 \leq m == moveTime[i].length ≤50\leq 50

  • 0≤0 \leq moveTime[i][j] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Minimum Time to Reach Last Room I

Try to solve the Find Minimum Time to Reach Last Room I problem.

Statement

You are given a 2D2 {D} integer array moveTime of size n×mn \times m, where moveTime[i][j] represents the minimum time in seconds that must elapse before you can start moving into room (i,j)(i, j).

You begin at room (0,0)(0, 0) at time t=0t = 0. From any room, you can move to any adjacent room sharing an edge in the four cardinal directions (up, down, left, right). Each move between adjacent rooms takes exactly 11 second. You can only start moving toward a room (i,j)(i, j) once the current time is greater than or equal to moveTime[i][j].

Return the minimum time in seconds required to reach the destination room (n−1,m−1)(n - 1, m - 1).

Constraints:

  • 2≤n==2 \leq n == moveTime.length ≤50\leq 50

  • 2≤m==2 \leq m == moveTime[i].length ≤50\leq 50

  • 0≤0 \leq moveTime[i][j] ≤109\leq 10^9