Simple java solution
Complexity\n- Time complexity: O(n^2 * k)\n\n- Space complexity: O(n^2)\n\n# Code\n\nclass Solution {\n    public double knightProbability(int n, int k, int row
# Complexity\n- Time complexity: $$O(n^2 * k)$$\n\n- Space complexity: $$O(n^2)$$\n\n# Code\n```\nclass Solution {\n    public double knightProbability(int n, int k, int row, int column) {\n        if(k==0)\n        {\n            return (double)1;\n        }\n        double dp[][] = new double[n][n];\n        dp[row][column]=1;\n        int val[][] = {{-2,1},{-1,2},{1,2},{2,1},{-2,-1},{-1,-2},{1,-2},{2,-1}};\n        for(int ind=1;ind<=k;ind++)\n        {\n            double dp1[][] = new double[n][n];\n            for(int i=0;i<n;i++)\n            {\n                for(int j=0;j<n;j++)\n                {\n                    if(dp[i][j]!=0)\n                    {\n                        for(int iterate[] : val)\n                        {\n                            int ind_x=i+iterate[0];\n                            int ind_y=j+iterate[1];\n                            if(ind_x>=0 && ind_y>=0 && ind_x<n && ind_y<n)\n                            {\n                                dp1[ind_x][ind_y]+=dp[i][j]/8.0;\n                            }\n                        }\n                    }\n                }\n            }\n            for(int i=0;i<n;i++)\n            {\n                for(int j=0;j<n;j++)\n                {\n                    dp[i][j]=dp1[i][j];\n                }\n            }\n        }\n        double ans=0;\n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<n;j++)\n            {\n                ans+=dp[i][j];\n            }\n        }\n        return ans;\n    }\n}\n```
['Dynamic Programming', 'Java']