Dijkstra wait till available
\nimport heapq\n\nclass Solution:\n    def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n        m = len(moveTime)\n        n = len(moveTime[0])\n   
```\nimport heapq\n\nclass Solution:\n    def minTimeToReach(self, moveTime: List[List[int]]) -> int:\n        m = len(moveTime)\n        n = len(moveTime[0])\n        dist = [[float(\'inf\')] * n for _ in range(m)]\n        dist[0][0] = 0\n        heap = [(0, 0, 0, True)]\n        while heap:\n            d, i, j, even = heapq.heappop(heap)\n            if (i, j) == (m - 1, n - 1):\n                return d\n            cost = 1 if even else 2\n            for x, y in [(i - 1, j), (i, j - 1), (i + 1, j), (i, j + 1)]:\n                if 0 <= x < m and 0 <= y < n and max(d, moveTime[x][y]) + cost < dist[x][y]:\n                    dist[x][y] = max(d, moveTime[x][y]) + cost\n                    heapq.heappush(heap, (dist[x][y], x, y, not even))\n```
['Python']