2D DP Explained with comments
Code\njava []\nclass Solution {\n    List<List<Integer>> nums;\n    int m, n;\n    Integer[][] memo;\n    public boolean findSafeWalk(List<List<Integer>> grid, 
# Code\n```java []\nclass Solution {\n    List<List<Integer>> nums;\n    int m, n;\n    Integer[][] memo;\n    public boolean findSafeWalk(List<List<Integer>> grid, int health) {\n        nums = grid;\n        m = grid.size();\n        n = grid.get(0).size();\n        memo = new Integer[m][n];\n        return help(0, 0, health);\n    }\n    \n    private boolean help(int i, int j, int h) {\n        // If the current cell is the bottom-right corner\n        if(i == m - 1 && j == n - 1)\n        {\n            if(nums.get(i).get(j) == 1) h--;//Check for enough health in the final cell\n\n            return h > 0;\n        }\n        // out-of-bound or insufficient health conditions\n        if(i < 0 || j < 0 || i >= m || j >= n || h <= 0) return false;\n\n        // if we are unable to go to (m - 1, n - 1) with memo[i][j] health then we cant go with h if memo[i][j] >= h\n        if(memo[i][j] != null && memo[i][j] >= h) return false;\n\n\n        memo[i][j] = h;\n\n        if (nums.get(i).get(j) == 1) h--;\n\n        // Check if health is exhausted after decrementing it\n        if(h <= 0) return false;\n\n        // explore \n        boolean ans = help(i + 1, j, h) || help(i - 1, j, h) || help(i, j + 1, h) || help(i, j - 1, h);\n        \n        return ans;\n    }\n}\n\n```
['Dynamic Programming', 'Recursion', 'Java']