totalHealth-minimumCost > 0 --> TRUE else FALSE
Intuition\ntake both 0 and 1 as cost take the path with minimum number of ones possibly 0 calculate the total cost(minimum possible cost), subtract it from heal
# Intuition\ntake both 0 and 1 as cost take the path with minimum number of ones possibly 0 calculate the total cost(minimum possible cost), subtract it from health if it is > 0 then return true else false. use Dijkstra Algorithm\n\n# Approach\nsame as intutution\n\n# Complexity\n- Time complexity:\nO(n^2)\n\n- Space complexity:\nO(n^2)\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    bool findSafeWalk(vector<vector<int>>& grid, int health) {\n        int n = grid.size();\n        int m = grid[0].size();\n        priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int,int>>>> pq;\n        vector<vector<int>> loss(n, vector<int>(m, INT_MAX));\n        loss[0][0] = grid[0][0];\n        pq.push({loss[0][0], {0, 0}});\n        vector<int> dr = {0, -1, 0, 1};\n        vector<int> dc = {-1, 0, 1, 0};\n        while (!pq.empty()) {\n            auto it = pq.top();\n            pq.pop();\n            int currLoss = it.first;\n            int row = it.second.first;\n            int col = it.second.second;\n            if (row == n - 1 && col == m - 1) {\n                break;\n            }\n            for (int i = 0; i < 4; i++) {\n                int newR = row + dr[i];\n                int newC = col + dc[i];\n                if (newR >= 0 && newR < n && newC >= 0 && newC < m) {\n                    int newLoss = currLoss + grid[newR][newC];\n                    if (newLoss < loss[newR][newC]) {\n                        loss[newR][newC] = newLoss;\n                        pq.push({newLoss, {newR, newC}});\n                    }\n                }\n            }\n        }\n        if(health-loss[n-1][m-1] <= 0) {\n            return false;\n        }\n        return true;\n    }\n};\n\n```
['C++']