Simple dijsktra based approach beats 71.61%
IntuitionJust apply simple dijsktra algo and add the damage to neighbor value of grid[i][j] and at last check whether the difference is greater than zero or not
# Intuition
Just apply simple dijsktra algo and add the damage to neighbor value of grid[i][j] and at last check whether the difference is greater than zero or not.

# Approach
Initialize:
Create a dist matrix to store the minimum damage taken to reach each cell.
Use a min-heap (priority queue) to process cells in increasing order of damage.
Push the starting cell (0,0) into the priority queue with its damage (grid[0][0]).

Process the priority queue:
Extract the cell with the least damage.
If the destination (m-1, n-1) is reached, check if remaining health > 0.
Explore 4 possible moves (up, down, left, right).
If a better path (less damage) is found, update dist and push the new cell into the queue.
Return true if the goal is reached with health > 0, otherwise false.

# Complexity
- Time complexity:
O((m×n)log(m×n))

- Space complexity:
O((m×n)

# Code
```cpp []
class Solution {
public:
    bool findSafeWalk(vector<vector<int>>& grid, int health) {
        int m = grid.size();
        int n = grid[0].size();
        vector<vector<int>> dist(m, vector<int>(n,INT_MAX));
        vector<pair<int, int>> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
        priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq;
        pq.push({grid[0][0], {0,0}});
        dist[0][0] = 0;
        while(!pq.empty()){
            auto it = pq.top();
            int damage = it.first;
            int row = it.second.first;
            int col = it.second.second;
            pq.pop();
            if(row == m-1 && col == n-1) return (health-damage)>0;
            for(auto dir: directions){
                int Nrow = row + dir.first;
                int Ncol = col + dir.second;
                if(Nrow>=0 && Nrow<m && Ncol>=0 && Ncol<n){
                    if(damage + grid[Nrow][Ncol] < dist[Nrow][Ncol]){
                        dist[Nrow][Ncol] = damage + grid[Nrow][Ncol];
                        pq.push({dist[Nrow][Ncol], {Nrow, Ncol}});
                    }
                }
            }
        }
        return false;
    }
};
```
['Graph', 'Shortest Path', 'C++']