Easy DP Solution || C++ Solution || Visited Method || Simple Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    bool f(int row,int col,int health,vector<vector<int>>&grid,vector<vector<int>>&visited,vector<vector<vector<int>>>&dp){\n        if(row==grid.size()-1 && col==grid[0].size()-1 && health>=1){\n            if(grid[row][col]==1 && health==1){\n                return false;\n            }\n            else{\n                return true;\n            }\n        }\n        if(row<0 || col<0|| row>=grid.size() || col>=grid[0].size() || health<1) {\n            return false;\n        }\n        if(visited[row][col]==1){\n            return false;\n        }\n        if(dp[row][col][health]!=-1){\n            return dp[row][col][health];\n        }\n        bool up=false;\n        bool down=false;\n        bool right=false;\n        bool left=false;\n        visited[row][col]=1;\n        if(grid[row][col]==1){\n            // if(row>0){\n                up=up||f(row-1,col,health-1,grid,visited,dp);\n            // }\n            down=down||f(row+1,col,health-1,grid,visited,dp);\n            right=right||f(row,col+1,health-1,grid,visited,dp);\n            // if(col>0){\n                left=left||f(row,col-1,health-1,grid,visited,dp);\n            // }\n        }\n        else{\n            // if(row>0){\n                up=up||f(row-1,col,health,grid,visited,dp);\n            // }\n            down=down|| f(row+1,col,health,grid,visited,dp);\n            right=right|| f(row,col+1,health,grid,visited,dp);\n            // if(col>0){\n                left=left|| f(row,col-1,health,grid,visited,dp);\n            // }\n            \n        }\n        visited[row][col]=0;\n        return dp[row][col][health]=up||down||right||left;\n    }\n    bool findSafeWalk(vector<vector<int>>& grid, int health) {\n        vector<vector<int>>visited(grid.size(),vector<int>(grid[0].size(),0));\n        vector<vector<vector<int>>>dp(grid.size(),vector<vector<int>>(grid[0].size(),vector<int>(health+1,-1)));\n        return f(0,0,health,grid,visited,dp);\n    }\n};\n```
['Dynamic Programming', 'Backtracking', 'Recursion', 'C++']