Clean and concise Memorization solution || C++
\nclass Solution {\npublic:\n    int iarr[8] = {-2,-2,-1,-1,1,1,2,2};\n    int jarr[8] = {-1,1,-2,2,-2,2,-1,1};\n    double solve(int row,int col,int n,int k,ve
```\nclass Solution {\npublic:\n    int iarr[8] = {-2,-2,-1,-1,1,1,2,2};\n    int jarr[8] = {-1,1,-2,2,-2,2,-1,1};\n    double solve(int row,int col,int n,int k,vector<vector<vector<double>>> &dp){\n        if(row < 0 or col < 0 or row >= n or col >= n) return 0;\n        if(k == 0) return 1;\n        if(dp[row][col][k] != -1) return dp[row][col][k];\n        \n        double ans = 0.0;\n        \n        for(int i=0;i<8;i++){\n            ans += solve(row+iarr[i], col+jarr[i], n, k-1, dp);\n        }\n        \n        return dp[row][col][k] = ans;\n    }\n    double knightProbability(int n, int k, int row, int col) {\n        vector<vector<vector<double>>> dp(n+1,vector<vector<double>> (n+1,vector<double> (k+1,-1)));\n        double fav = solve(row,col,n,k,dp);\n        double total = pow(8,k);\n        return fav/total;\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C', 'C++']