Python DP Solution | Memoization | Easy to understand
\n\n# Code\n\nclass Solution:\n    def earliestAndLatest(self, n: int, firstPlayer: int, secondPlayer: int) -> List[int]:\n        @lru_cache(None)\n        def
\n\n# Code\n```\nclass Solution:\n    def earliestAndLatest(self, n: int, firstPlayer: int, secondPlayer: int) -> List[int]:\n        @lru_cache(None)\n        def dp(left, right, curPlayers, numGamesAlreadyPlayed):\n            if left > right:  \n                dp(right, left, curPlayers, numGamesAlreadyPlayed)\n            if left == right: \n                ans.add(numGamesAlreadyPlayed)\n            for i in range(1, left + 1):\n                for j in range(left - i + 1, right - i + 1):\n                    if not (curPlayers + 1) // 2 >= i + j >= left + right - curPlayers // 2: \n                        continue\n                    dp(i, j, (curPlayers + 1) // 2, numGamesAlreadyPlayed + 1)\n\n        ans = set()\n        dp(firstPlayer, n - secondPlayer + 1, n, 1)\n        return [min(ans), max(ans)]\n```
['Dynamic Programming', 'Memoization', 'Python', 'Python3']