Easy dp + bfs solution || step by step explanation
Intuition\n1. The basic idea is to find the route from where we can reach last cell with least health lost.\n2. We use bfs traversal to move in grid.\n3. dp to 
# Intuition\n1. The basic idea is to find the route from where we can reach last cell with least health lost.\n2. We use bfs traversal to move in grid.\n3. dp to store max health.\n4. I hope it helps. Commented the code to make it more clear. If your fingers can reach upvote btn please consider to click it.\n\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    bool findSafeWalk(vector<vector<int>>& grid, int health) {\n        int row = grid.size();\n        int col = grid[0].size();\n\n        // Directions for up, down, left, right\n        vector<pair<int, int>> directions = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};\n\n        // BFS queue, store the position and remaining health\n        queue<pair<pair<int, int>, int>> q;\n\n        // DP table to store the maximum health remaining at each cell\n        vector<vector<int>> dp(row, vector<int>(col, -1));\n\n        // Start from the top-left corner with the initial health\n        q.push({{0, 0}, health - grid[0][0]});\n        dp[0][0] = health - grid[0][0];\n\n        while (!q.empty()) {\n            auto [pos, currentHealth] = q.front();\n            q.pop();\n            int x = pos.first;\n            int y = pos.second;\n\n            // If we reached the bottom-right corner and still have health left\n            if (x == row - 1 && y == col - 1 && currentHealth > 0) {\n                return true;\n            }\n\n            // Explore all four directions\n            for (auto [dx, dy] : directions) {\n                int newX = x + dx;\n                int newY = y + dy;\n\n                // Check if new position is within bounds\n                if (newX >= 0 && newX < row && newY >= 0 && newY < col) {\n                    int newHealth = currentHealth - grid[newX][newY];\n\n                    // Only explore if we still have health left and this path is better than previously explored paths\n                    if (newHealth > 0 && newHealth > dp[newX][newY]) {\n                        dp[newX][newY] = newHealth;\n                        q.push({{newX, newY}, newHealth});\n                    }\n                }\n            }\n        }\n        // If we exhaust the queue without reaching the bottom-right corner with positive health, return false\n        return false;\n    }\n};\n\n```
['C++']