C++ || BFS
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach : \nThe code performs a BFS to find a path from the top-left to the bottom
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : \nThe code performs a BFS to find a path from the top-left to the bottom-right of a grid, ensuring that health levels remain positive throughout the journey\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(N * M)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N * M)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    bool findSafeWalk(vector<vector<int>>& grid, int H) {\n        int n = grid.size();\n        int m = grid[0].size();\n        vector<vector<int>> vis(n, vector<int>(m, -1));\n        queue<pair<int, pair<int, int>>> q;\n        q.push({H-grid[0][0], {0, 0}});\n        vis[0][0] = H-grid[0][0];\n        if(vis[0][0] <= 0) return false;\n        vector<int> arr = {0, 1, 0, -1};\n        vector<int> brr = {1, 0, -1, 0};\n        while(!q.empty()){\n            int h = q.front().first;\n            int x = q.front().second.first;\n            int y = q.front().second.second;\n            q.pop();\n            if(x==n-1 && y==m-1 && h>0)\n                return 1;\n            for(int i=0; i<4; i++){\n                int nx = x + arr[i];\n                int ny = y + brr[i];\n                if(nx>=0 && ny>=0 && nx<n && ny<m){\n                    int nh = h - (grid[nx][ny]==1);\n                    if(nh>0 && nh>vis[nx][ny]){\n                        q.push({nh, {nx, ny}});\n                        vis[nx][ny] = nh;\n                    }\n                }\n            }\n        }\n        return 0;\n    }\n};\n```
['Breadth-First Search', 'C++']