[Python 3]DP + Bitmask
```\nclass Solution:\n    def maxMoves(self, kx: int, ky: int, positions: List[List[int]]) -> int:\n        \n        n = len(positions)\n        \n        dirs
```\nclass Solution:\n    def maxMoves(self, kx: int, ky: int, positions: List[List[int]]) -> int:\n        \n        n = len(positions)\n        \n        dirs = [(1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1)]\n        \n        @cache\n        def helper(cx, cy, dx, dy):\n            \n            cnt = 0\n            \n            q = [(cx, cy)]\n            vis = defaultdict(lambda: inf, {(cx, cy): 0})\n            while q:\n                new_q = []\n                for x, y in q:\n                    if x == dx and y == dy:\n                        return cnt\n                    for a, b in dirs:\n                        nx, ny = x + a, y + b\n                        if (0 <= nx < 50) and (0 <= ny < 50) and vis[nx, ny] > cnt + 1:\n                            vis[nx, ny] = cnt + 1\n                            new_q.append((nx, ny))\n                q = new_q\n                cnt += 1\n            \n        \n        @cache\n        def dp(x, y, mask, max_round):\n            if mask == (1 << n) - 1:\n                return 0\n            \n            ans = 0 if max_round else inf\n            for i in range(n):\n                if mask & (1 << i):\n                    continue                \n                dx, dy = positions[i]\n                min_moves = helper(x, y, dx, dy)\n                if max_round:\n                    ans = max(ans, min_moves + dp(dx, dy, mask | (1 << i), max_round ^ 1))\n                else:\n                    ans = min(ans, min_moves + dp(dx, dy, mask | (1 << i), max_round ^ 1))\n            return ans\n        \n        return dp(kx, ky, 0, 1)
['Dynamic Programming', 'Bitmask', 'Python', 'Python3']