C++✅✅ | Faster🚀 than 90%🔥| DFS 🍀+ 3D DP🍀 | Concise Code |
PLEASE DO UPVOTE!!!\n\n# Code\n\nclass Solution {\npublic:\n\ndouble dp[30][30][105];\nint X[8]={ 2, 1, -1, -2, -2, -1, 1, 2 };\nint Y[8]={ 1, 2, 2, 1, -1, -2, 
# PLEASE DO UPVOTE!!!\n\n# Code\n```\nclass Solution {\npublic:\n\ndouble dp[30][30][105];\nint X[8]={ 2, 1, -1, -2, -2, -1, 1, 2 };\nint Y[8]={ 1, 2, 2, 1, -1, -2, -2, -1 };\n\ndouble dfs(int i,int j,int k, int n)\n{\n    if(i < 0 || j < 0 ||i >= n || j >= n) return 0;\n    if(k == 0) return 1;\n    if(dp[i][j][k] != 0) return dp[i][j][k];\n\n    double res = 0;\n\n    for(int l = 0;l < 8; ++l)\n    {\n      int x = i + X[l];\n      int y = j + Y[l];\n      res += dfs(x,y,k-1,n);\n    }\n    return dp[i][j][k] += (res/8.0);\n}\n\n    double knightProbability(int n, int k, int row, int column) {\n\n        memset(dp,0,sizeof(dp));\n        return dfs(row,column,k,n); \n    }\n};\n\n```
['C++']