Python
At the start, the knight is at (r, c) with probability 1 (and anywhere else with probability 0). Then update those probabilities over K moves.\n\n    def knight
At the start, the knight is at (r, c) with probability 1 (and anywhere else with probability 0). Then update those probabilities over K moves.\n\n    def knightProbability(self, N, K, r, c):\n        p = {(r, c): 1}\n        for _ in range(K):\n            p = {(r, c): sum(p.get((r+i, c+j), 0) + p.get((r+j, c+i), 0) for i in (1, -1) for j in (2, -2)) / 8\n                 for r in range(N) for c in range(N)}\n        return sum(p.values())\n\nShorter and maybe nicer version, influenced a bit by @flamesofmoon's [solution](https://discuss.leetcode.com/topic/105934/python-with-explanations):\n\n    def knightProbability(self, N, K, r, c):\n        p = {(r, c): 1}\n        for _ in range(K):\n            p = {(r, c): sum(p.get((r+i, c+j), 0) for x in (1, 2) for i in (x, -x) for j in (3-x, x-3)) / 8\n                 for r in range(N) for c in range(N)}\n        return sum(p.values())
[]