Java Clean 2 Approach Solution with Brief Explanation || Optimize
Complexity\n- Time complexity:O(nm105)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(3030105)\n Add your space complexity here, e.g. O(n) 
# Complexity\n- Time complexity:$$O(n*m*105)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(30*30*105)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    int[][] dir = { { 2, 1 }, { 1, 2 }, { -1, 2 }, { -2, 1 }, { -2, -1 }, { -1, -2 }, { 1, -2 }, { 2, -1 } };\n\n    // RECURSIVE SOLUTION \n    private double SolveRec(int n, int k, int row, int column) {\n        // Base Case\n        if (row < 0 || column < 0 || row >= n || column >= n) {\n            return 0;\n        }\n        if (k == 0) {\n            return 1;\n        }\n\n        double temp = 0;\n        for (int i = 0; i < 8; i++) {\n            int x_row = row + dir[i][0];\n            int y_col = column + dir[i][1];\n            temp += SolveRec(n, k - 1, x_row, y_col);\n        }\n        return (temp / 8.0);\n    }\n\n\n\n    // DP + MEMOIZATION\n    private double solveMemo(int n, int k, int row, int column, double[][][] dp) {\n        // Base Case\n        if (row < 0 || column < 0 || row >= n || column >= n) {\n            return 0;\n        }\n        if (k == 0) {\n            return 1;\n        }\n\n        // step-2 => If dp[][][] is not null then just return its value\n        if (dp[row][column][k] != 0)\n            return dp[row][column][k];\n\n        // step-3 => if not calculated yet just calculate it and return it.\n        double temp = 0;\n        for (int i = 0; i < 8; i++) {\n            int x_row = row + dir[i][0];\n            int y_col = column + dir[i][1];\n            temp += solveMemo(n, k - 1, x_row, y_col, dp);\n        }\n        return dp[row][column][k] += (temp / 8.0);\n    }\n\n\n\n\n    public double knightProbability(int n, int k, int row, int column) {\n        // return SolveRec(n, k, row, column);\n\n\n\n        // DP + MEMOIZATION\n        double[][][] dp = new double[30][30][105];\n        for (double[][] i : dp) {\n            for (double[] j : i) {\n                Arrays.fill(j, 0);\n            }\n        }\n\n        return solveMemo(n, k, row, column, dp);\n    }\n}\n```
['Dynamic Programming', 'Recursion', 'Memoization', 'Java']