Java DP with memory
Use DP with memory\n* Divide players to 3 parts because of the first and second players\n  * xFySz, left has x players, middle has y players, right has z player
* Use DP with memory\n* Divide players to 3 parts because of the first and second players\n  * xFySz, left has x players, middle has y players, right has z players\n```\nclass Solution {\n    int[][][][] dp = new int[28][28][28][2];\n    public int[] earliestAndLatest(int n, int f, int s) {\n        return helper(f-1, s-f-1, n-s);\n    }\n    \n    int[] helper(int x, int y, int z) {\n        if (x == z)\n            return new int[]{1, 1};\n        if (x > z) // Make sure z > x\n            return helper(z, y, x);\n        if (dp[x][y][z][0] > 0)\n            return dp[x][y][z];\n        int a = x, b = y, c = z;\n        c--; // Remove because of the First Player\n        if (a+b < c) // Remove because of the Second Player\n            c--;\n        else if (a+b > c)\n            b--;\n        dp[x][y][z][0] = 100;\n        int n = (a+b+c)/2; // Players to remove\n        for (int i = 0; i <= a; i++)\n            for (int j = a-i; j <= c-i; j++) {\n                int k = a+b+c-n-i-j;\n                if (k >= 0 && k <= b) {\n                    int[] tmp = helper(i, k, j);\n                    dp[x][y][z][0] = Math.min(dp[x][y][z][0], tmp[0] + 1);\n                    dp[x][y][z][1] = Math.max(dp[x][y][z][1], tmp[1] + 1);\n                }\n            }\n        return dp[x][y][z];\n    }\n}\n```
[]