Simple Solution || C++
\n# Code\ncpp []\nclass Solution {\n    int memo[51][51][101];\n    bool solve(int i,int j,vector<vector<int>>& grid, int& health){\n        if(i<0 || j<0 || i>
\n# Code\n```cpp []\nclass Solution {\n    int memo[51][51][101];\n    bool solve(int i,int j,vector<vector<int>>& grid, int& health){\n        if(i<0 || j<0 || i>=grid.size() || j>= grid[0].size() || grid[i][j]==-1 || health<0)return false;\n        if(i == grid.size()-1 && j == grid[0].size()-1){\n            if(grid[i][j] == 1) return (health > 1);\n            if(grid[i][j] == 0) return (health > 0);\n            return false;\n        }\n        if(memo[i][j][health]!=-1)return memo[i][j][health];\n        \n       \n        int val = grid[i][j];\n        grid[i][j] = -1;\n        if(val == 1)health = health-1;\n        \n            if(solve(i+1,j,grid,health))return true;\n            if(solve(i,j+1,grid,health))return true;;\n            if(solve(i-1,j,grid,health))return true;;\n            if(solve(i,j-1,grid,health))return true;;\n        \n        if(val == 1)health = health+1;\n        \n        grid[i][j] = val;\n        return memo[i][j][health] = false;\n\n\n    }\n    \npublic:\n    bool findSafeWalk(vector<vector<int>>& grid, int health) {\n        memset(memo,-1,sizeof(memo));\n        return solve(0,0,grid,health);\n    }\n};\n```
['C++']