Dijkstra's || Safe Walk || C++.
Intuitionsince we need to mazimize the health thus we need to find a path that consumes the minimum health.ApproachWe use dijkstra's algo to find the minimum he
# Intuition
since we need to mazimize the health thus we need to find a path that consumes the minimum health.

# Approach
We use dijkstra's algo to find the minimum health required.

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

- Space complexity:
O(n.m)

# Code
```cpp []
class Solution {
public:
    bool findSafeWalk(vector<vector<int>>& grid, int health) {
        int n = grid.size(),m=grid[0].size();
        vector<vector<int>> dist(n,vector<int>(m,1e8));
        priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<>> pq;
        //{reqHealth,{i,j}}
        dist[0][0] = grid[0][0];
        pq.push({grid[0][0],{0,0}});

        int drow[] = {-1,0,1,0};
        int dcol[] = {0,1,0,-1};
        while(!pq.empty())
        {
            auto it = pq.top();
            pq.pop();
            int chlth = it.first;
            int crow = it.second.first;
            int ccol = it.second.second;
            if(crow==n-1 && ccol==m-1)
            return health-chlth>0;
            for(int i=0;i<4;i++)
            {
                int nrow = crow + drow[i];
                int ncol = ccol + dcol[i];
                if(nrow>=0 && nrow<n && ncol>=0 && ncol<m && (chlth + grid[nrow][ncol] < dist[nrow][ncol]))
                {
                    dist[nrow][ncol] = chlth + grid[nrow][ncol];
                    pq.push({dist[nrow][ncol],{nrow,ncol}});
                }
            }
        }
        return false;
    }
};
```
['C++']