Heap Python Simple 
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# 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 findSafeWalk(self, grid: List[List[int]], health: int) -> bool:
        m,n = len(grid),len(grid[0])
        heap = []
        visited = [[False]*n for _ in range(m)]
        visit = set()
        if grid[0][0] == 1:
            health-=1
        heappush(heap,(-health,0,0))
        directions = [(0,1),(1,0),(-1,0),(0,-1)]
        while heap:
            hp,x,y = heappop(heap)
            if x == m-1 and y == n-1:
                if hp <= -1:
                    return True
            if visited[x][y] == True:
                continue
            else:
                visited[x][y] = True
            for dx,dy in directions:
                nx,ny = dx+x,dy+y
                if 0 <= nx < m and 0 <= ny < n:
                    if grid[nx][ny] == 1:
                        heappush(heap,(hp+1,nx,ny))
                    else:
                        heappush(heap,(hp,nx,ny))
        return False

```
['Python3']