Djiskira's
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
        If the time so far is less than the timeTomove at the current index, then add the difference tot he time so far. 
        find a way to keep track of what was added last time

        heap -> distance, node, previous_appended
        distance -> 2d Grid array of how long it took to reach there
        

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def minTimeToReach(self, moveTime: List[List[int]]) -> int:
        '''
        If the time so far is less than the timeTomove at the current index, then add the difference tot he time so far. 
        find a way to keep track of what was added last time

        heap -> distance, node, previous_appended
        distance -> 2d Grid array of how long it took to reach there
        
        '''

        
        distance = [[float('inf')] * len(moveTime[0]) for _ in range(len(moveTime))]
        distance[0][0] = moveTime[0][0]
        heap = [(0, [0, 0], 2)]

        while heap:
            distance_, node, previous = heapq.heappop(heap)
            if distance_ > distance[node[0]][node[1]]:
                continue
            for index in [0, 1]:
                for adding in [1, -1]:
                    new_node = list(node)
                    new_node[index] += adding
                    row, col = new_node
                    if index == 0 and row >= len(moveTime) or row < 0:
                        continue 
                    if index == 1 and col >= len(moveTime[0]) or col < 0:
                        continue
                    appending = 1 if previous == 2 else 2
                    new_distance = distance_ + appending + max(0, moveTime[row][col] - distance_)
                    if new_distance < distance[row][col]:
                        distance[new_node[0]][new_node[1]] = new_distance 
                        heappush(heap, (new_distance, new_node, appending))
        
        return distance[-1][-1]
```
['Python3']