EASY PYTHON SOLUTION USING DFS
Code\n\nclass Solution:\n    def dp(self,x,y,n,visited,k):\n        if k<0:\n            return 1\n        if (x<0 or x>=n) or (y<0 or y>=n):\n            retur
# Code\n```\nclass Solution:\n    def dp(self,x,y,n,visited,k):\n        if k<0:\n            return 1\n        if (x<0 or x>=n) or (y<0 or y>=n):\n            return 0\n        if (x,y,k) in visited:\n            return visited[(x,y,k)]\n        a=self.dp(x+2,y+1,n,visited,k-1)*1/8\n        b=self.dp(x+2,y-1,n,visited,k-1)*1/8\n        c=self.dp(x-2,y+1,n,visited,k-1)*1/8\n        d=self.dp(x-2,y-1,n,visited,k-1)*1/8\n        e=self.dp(x+1,y+2,n,visited,k-1)*1/8\n        f=self.dp(x+1,y-2,n,visited,k-1)*1/8\n        g=self.dp(x-1,y+2,n,visited,k-1)*1/8\n        h=self.dp(x-1,y-2,n,visited,k-1)*1/8\n        visited[(x,y,k)]=a+b+c+d+e+f+g+h\n        return a+b+c+d+e+f+g+h\n        \n    def knightProbability(self, n: int, k: int, row: int, column: int) -> float:\n        return self.dp(row,column,n,{},k)\n\n```
['Python3']