Beats 100 % | Simple and easy solution | Java
\n\n# Code\njava []\nclass Solution {\n    public boolean findSafeWalk(List<List<Integer>> grid, int health) {\n        int rows = grid.size();\n        int col
![Screenshot 2024-09-14 at 9.32.08\u202FPM.png](https://assets.leetcode.com/users/images/33cedab6-83b1-4f7f-bd4c-1fd6bfb398af_1726329740.1085758.png)\n\n# Code\n```java []\nclass Solution {\n    public boolean findSafeWalk(List<List<Integer>> grid, int health) {\n        int rows = grid.size();\n        int cols = grid.get(0).size();\n\n        int[][] directions = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}};\n        Queue<int[]> queue = new LinkedList<>();\n        int[][] visited = new int[rows][cols];\n\n        queue.offer(new int[] {0, 0});\n        visited[0][0] = health - grid.get(0).get(0);\n        while (!queue.isEmpty()) {\n            int[] current = queue.poll();\n            int row = current[0];\n            int col = current[1];\n            int currHealth = visited[row][col];\n\n            if (row == rows - 1 && col == cols - 1) {\n                return true;\n            }\n\n            for (int[] dir : directions) {\n                int newRow = row + dir[0];\n                int newCol = col + dir[1];\n\n                if (newRow >= 0 && newRow < rows && newCol >= 0 && newCol < cols) {\n                    int newHealth = currHealth - grid.get(newRow).get(newCol);\n                    if (newHealth >= 0 && newHealth > visited[newRow][newCol]) {\n                        visited[newRow][newCol] = newHealth;\n                        queue.offer(new int[] {newRow, newCol});\n                    }\n                }\n            }\n        }\n        \n        return false;\n    }\n}\n```
['Java']