3D memo approach/ evolve from recursion
class Solution {\n    public:\n    double dp[26][26][101];\n    double knightProbability(int n, int k, int row, int col) {\n        \n        \n        if(row<0
class Solution {\n    public:\n    double dp[26][26][101];\n    double knightProbability(int n, int k, int row, int col) {\n        \n        \n        if(row<0 || col<0 || row>=n || col>=n) return 0;\n        \n        if(k==0) return 1;\n        \n        \n        if(dp[row][col][k]!=0)\n            return dp[row][col][k];\n        \n        double a=knightProbability(n,k-1,row-2,col+1);\n        double b=knightProbability(n,k-1,row-1,col+2);\n        double c=knightProbability(n,k-1,row+2,col+1);\n        double d=knightProbability(n,k-1,row+1,col+2);\n        double e=knightProbability(n,k-1,row+2,col-1);\n        double f=knightProbability(n,k-1,row+1,col-2);\n        double g=knightProbability(n,k-1,row-1,col-2);\n        double h=knightProbability(n,k-1,row-2,col-1);\n        \n        return dp[row][col][k]=(a+b+c+d+e+f+g+h)/8;\n        \n        \n    }\n};
['Dynamic Programming', 'Recursion', 'Memoization']