Minimum Time to Visit Cell in a Grid
You are given an
m x n matrix grid of non-negative integers. Each grid[row][col] represents the minimum time required to enter that cell. You start at (0, 0) at time t = 0. In each second, you can move to an adjacent cell (up, down, left, right). You can only enter a cell if the current time plus one second is greater than or equal to the value at that cell. If you cannot reach a cell at the required time, you may move back and forth between previously visited cells to wait. Return the minimum time to reach the bottom-right cell (m-1, n-1). If it is impossible, return -1. Constraints: m == grid.length, n == grid[i].length 2 <= m, n <= 1000 0 <= grid[i][j] <= 10^5 grid[0][0] == 0JavaDijkstra's AlgorithmPriorityQueue
00