[Python3] Simple Dijkstra with modification
Intuition\nA small change to Dijkstra\'s algorithm is that we move back and forth until a new cell unlocks after some time. We calculate when the neighbor cell 
# Intuition\nA small change to Dijkstra\'s algorithm is that we move back and forth until a new cell unlocks after some time. We calculate when the neighbor cell becomes available and push it into the heap with that time.\n\n# Code\n```python3 []\nclass Solution:\n    def minimumTime(self, grid: List[List[int]]) -> int:\n        ROWS, COLS = len(grid), len(grid[0])\n        directions = [[1, 0], [-1, 0], [0, 1], [0, -1]]\n        heap = [(grid[0][0], 0, 0)]\n        visit = set()\n        visit.add((0, 0))\n\n        if grid[0][1] > 1 and grid[1][0] > 1:\n            return -1\n\n        while heap:\n            time, r, c = heapq.heappop(heap)\n\n            if r == ROWS - 1 and c == COLS - 1:\n                return time\n\n            for dr, dc in directions:\n                nr, nc = r + dr, c + dc\n                if 0 <= nr < ROWS and 0 <= nc < COLS and (nr, nc) not in visit:\n                    visit.add((nr, nc))\n                    if grid[nr][nc] <= time + 1:\n                        heapq.heappush(heap, [time + 1, nr, nc])\n                    else:\n                        if (grid[nr][nc] - time) % 2 == 0:\n                            heapq.heappush(heap, [grid[nr][nc] + 1, nr, nc])\n                        else:\n                            heapq.heappush(heap, [grid[nr][nc], nr, nc])\n                        \n        return -1\n\n\n```
['Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Shortest Path', 'Python3']