Beats 84% c++
class Solution {\npublic:\n    \n   double DP[25][25][101] = {0};\n   int row[8] = {1,1,-1,-1,2,2,-2,-2};\n   int col[8] = {2,-2,2,-2,1,-1,1,-1};\n    \n    dou
class Solution {\npublic:\n    \n   double DP[25][25][101] = {0};\n   int row[8] = {1,1,-1,-1,2,2,-2,-2};\n   int col[8] = {2,-2,2,-2,1,-1,1,-1};\n    \n    double knightProbability(int N, int K, int r, int c) {\n        \n    \n        if(r<0 || r>=N || c<0 || c>=N)\n            return 0;\n        \n        \n        if(K==0)\n            return 1.0;\n        \n        if(N<=2)\n            return 0;\n        \n        if(DP[r][c][K])\n            return DP[r][c][K];\n            \n        double ans = 0;    \n        for(int i=0;i<8;i++)\n            ans += knightProbability(N,K-1,r+row[i],c+col[i]);\n        \n        return DP[r][c][K] = ans/8.0;\n        \n    }\n};
[]