[Python ] DP + Bitmask + Memoization
\nclass Solution:\n    def earliestAndLatest(self, n: int, firstPlayer: int, secondPlayer: int) -> List[int]:\n        self.first = min(firstPlayer-1, secondPla
```\nclass Solution:\n    def earliestAndLatest(self, n: int, firstPlayer: int, secondPlayer: int) -> List[int]:\n        self.first = min(firstPlayer-1, secondPlayer-1)\n        self.second = max(firstPlayer-1, secondPlayer-1)\n        self.n=n-1\n        self.dp = {}\n        return self.rounds_helper((1<<n)-1, 0, self.n, 1)\n    \n    def rounds_helper(self, state, left, right, curr_round):\n        if left >= right:\n            return self.rounds_helper(state, 0, self.n, curr_round+1)\n        elif (state&(1<<left)) == 0:\n            return self.rounds_helper(state, left+1, right, curr_round)\n        elif (state&(1<<right)) == 0:\n            return self.rounds_helper(state, left, right-1, curr_round)\n        elif left == self.first and right == self.second:\n            return [curr_round, curr_round]\n        else:\n            key = (state, left, right)\n            if key in self.dp:\n                return self.dp[key]\n            \n            res = [self.n, 0]\n            if right != self.first and right != self.second:\n                val = self.rounds_helper(state^(1<<right), left+1, right-1, curr_round)\n                res[0] = min(res[0], val[0])\n                res[1] = max(res[1], val[1])\n            if left != self.first and left != self.second:\n                val = self.rounds_helper(state^(1<<left), left+1, right-1, curr_round)\n                res[0] = min(res[0], val[0])\n                res[1] = max(res[1], val[1])\n            \n            self.dp[key] = res\n            return res\n            \n        \n```
[]