JavaScript DP
\nvar knightProbability = function(N, K, r, c) {\n    \n    const dp = new Array(N);\n    const movesR = [2,2,-2,-2,1,1,-1,-1];\n    const movesC = [1,-1,1,-1,2
```\nvar knightProbability = function(N, K, r, c) {\n    \n    const dp = new Array(N);\n    const movesR = [2,2,-2,-2,1,1,-1,-1];\n    const movesC = [1,-1,1,-1,2,-2,2,-2]; \n    \n    for(let col = 0; col < dp.length; col++) {\n        dp[col] = new Array(N);\n        for(let k = 0; k < dp[col].length; k++) {\n            dp[col][k] = [1]; // 0 move has 100% of staying on the board\n        }\n    }\n    \n    for(let s = 1; s < K + 1; s++) {\n        for(let i = 0; i < N; i++) {\n            for(let j = 0; j < N; j++) {\n                let probability = 0.0;\n                for(let m = 0; m < 8; m++) {\n                    const nextRow = i + movesR[m];\n                    const nextCol = j + movesC[m];\n                    if(nextRow >= 0 && nextRow < N && nextCol >= 0 && nextCol < N) {\n                        probability += dp[nextRow][nextCol][s-1]/8.0; // % of chance out of 8 moves\n                    }\n                }\n                dp[i][j][s] = probability;\n            }\n        }\n    }\n    \n    return dp[r][c][K];\n};\n```
[]