C# DFS with memorization
\npublic class Solution\n{\n    public int[] EarliestAndLatest(int n, int firstPlayer, int secondPlayer)\n    {\n        var res = DFS(n, firstPlayer - 1, secon
```\npublic class Solution\n{\n    public int[] EarliestAndLatest(int n, int firstPlayer, int secondPlayer)\n    {\n        var res = DFS(n, firstPlayer - 1, secondPlayer - 1, new (int Min, int Max)?[n + 1, n + 1, n + 1]);\n        return new int[] { res.Min, res.Max };\n    }\n\n    private (int Min, int Max) DFS(int len, int firstPlayer, int secondPlayer, (int Min, int Max)?[,,] memo)\n    {\n        if (firstPlayer + secondPlayer + 1 == len)\n            return (1, 1);\n\n        if (memo[len, firstPlayer, secondPlayer].HasValue)\n            return memo[len, firstPlayer, secondPlayer].Value;\n\n        int min = len;\n        int max = 0;\n        int nextLen = (len + 1) / 2;\n        for (int mask = 0; mask < (1 << nextLen); mask++)\n        {\n            int nextFirstPlayer = firstPlayer;\n            int nextSecondPlayer = secondPlayer;\n            bool valid = true;\n            for (int n = 0; n < len / 2; n++)\n            {\n                int m = (mask & 1 << n) == 0 ? n : len - n - 1;\n                if (m == firstPlayer || m == secondPlayer)\n                    valid = false;\n                if (m < firstPlayer)\n                    nextFirstPlayer--;\n                if (m < secondPlayer)\n                    nextSecondPlayer--;\n            }\n\n            if (!valid) continue;\n\n            var next = DFS(nextLen, nextFirstPlayer, nextSecondPlayer, memo);\n            min = Math.Min(min, next.Min + 1);\n            max = Math.Max(max, next.Max + 1);\n        }\n\n        memo[len, firstPlayer, secondPlayer] = (min, max);\n        return memo[len, firstPlayer, secondPlayer].Value;\n    }\n}\n```
[]