Share My Intuitive Recursive Java Solution
\nclass Solution {\n    private static final int[][] dirs = {{-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}, {-1, -2}, {-2, -1}};\n    Map<String, Double> m
```\nclass Solution {\n    private static final int[][] dirs = {{-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}, {-1, -2}, {-2, -1}};\n    Map<String, Double> map = new HashMap<>();\n    public double knightProbability(int N, int K, int r, int c) {\n        if (r < 0 || r >= N || c < 0 || c >= N || K < 0) {\n            return 0;\n        }\n        if (K == 0) {\n            return 1;\n        }\n        String key = K + "," + r + "," + c;\n        if (map.containsKey(key)) {\n            return map.get(key);\n        }\n        double result = 0;\n        for (int[] dir: dirs) {\n            int row = r + dir[0];\n            int col = c + dir[1];\n            result += knightProbability(N, K - 1, row, col);\n        }\n        map.put(key, 0.125 * result);\n        return 0.125 * result;\n    }\n}\n```
[]