Simple BFS approach
\n\n# Code\npython3 []\nclass Solution:\n    def findSafeWalk(self, grid: List[List[int]], health: int) -> bool:\n        \n        m, n = len(grid), len(grid[0
\n\n# Code\n```python3 []\nclass Solution:\n    def findSafeWalk(self, grid: List[List[int]], health: int) -> bool:\n        \n        m, n = len(grid), len(grid[0])\n\n        directions = [[0, 1], [0, -1], [1, 0], [-1, 0]]\n        \n        queue = deque([(0, 0, health + (0 if grid[0][0] == 0 else -1))])\n        \n        visited = [[-1] * n for _ in range(m)]\n        visited[0][0] = health + (0 if grid[0][0] == 0 else -1)\n\n        while queue:\n            x, y, cur_health = queue.popleft()\n\n            for dx, dy in directions:\n                nx, ny = x + dx, y + dy\n\n                if 0 > nx or 0 > ny or nx >= m or ny >= n :\n                    continue\n\n                new_health = cur_health - grid[nx][ny]\n\n                if nx == m-1 and ny == n-1 and new_health > 0:\n                    return True\n\n\n                if new_health > visited[nx][ny]:\n                    visited[nx][ny] = new_health\n                    queue.append((nx, ny, new_health))\n\n        return False\n```
['Breadth-First Search', 'Graph', 'Shortest Path', 'Python3']