[Java] straightforward DFS solution, simulation
\tint first;\n    int second;\n    public int[] earliestAndLatest(int n, int firstPlayer, int secondPlayer) {\n        first = firstPlayer;\n        second = se
\tint first;\n    int second;\n    public int[] earliestAndLatest(int n, int firstPlayer, int secondPlayer) {\n        first = firstPlayer;\n        second = secondPlayer;\n        List<Integer> list = new ArrayList<>();\n        for (int i = 1; i <= n; i++) {\n            list.add(i);\n        }\n        int[] res = new int[2];\n        res[0] = n;\n        res[1] = 0;\n        dfs(list, new ArrayList<>(), 1, n, res, 0);\n        return res;\n    }\n    \n    void dfs(List<Integer> list, List<Integer> temp, int round, int n, int[] res, int i) {\n        \n        if (i > n - 1- i) {\n            List<Integer> next = new ArrayList<>(temp);\n            Collections.sort(next);\n            dfs(next, new ArrayList<>(), round + 1, next.size(), res, 0);\n            return;\n        }\n        \n        if (list.get(i) == first && list.get(n-1-i) == second) {\n            res[0] = Math.min(res[0], round);\n            res[1] = Math.max(res[1], round);\n            return;\n        }\n        \n        if (list.get(i) == first || list.get(i) == second) {\n            temp.add(list.get(i));\n            dfs(list, temp, round, n, res, i+1);\n            temp.remove(temp.size() - 1);\n        } else if (list.get(n-1-i) == second || list.get(n-1-i) == first) {\n            temp.add(list.get(n-1-i));\n            dfs(list, temp, round, n, res, i+1);\n            temp.remove(temp.size() - 1);\n        } else {\n            temp.add(list.get(i));\n            dfs(list, temp, round, n, res, i+1);\n            temp.remove(temp.size() - 1);\n\n            temp.add(list.get(n-1-i));\n            dfs(list, temp, round, n, res, i+1);\n            temp.remove(temp.size() - 1);\n        }\n        \n    }
[]