C++ DP+permutation  | Easy to read
\nclass Solution {\nprivate:\n    int dp[28][28][28];\n    int Min = INT_MAX, Max = 0;\n    void perm(int len, int f, int s, int round, int i1, int i2, int stat
```\nclass Solution {\nprivate:\n    int dp[28][28][28];\n    int Min = INT_MAX, Max = 0;\n    void perm(int len, int f, int s, int round, int i1, int i2, int state){\n        if(i1 < i2){\n            if(i2 != f && i2 != s){\n                perm(len, f, s, round, i1+1, i2-1, state | (1 << i1));     \n            }\n            if(i1 != f && i1 != s){\n                perm(len, f, s, round, i1+1, i2-1, state | (1 << i2));     \n            }\n            return;\n        }\n        \n        if(i1 == i2){state |= (1<<i1);}\n        \n        int mask = 1;\n        int count = 0;\n        int f_nxt, s_nxt;\n        for(int i = 0; i < len; i++){\n            if(i == f){f_nxt = count;}\n            else if(i == s){s_nxt = count;}\n            if(mask & state){count++;}\n            mask <<= 1;\n        }\n            \n        dfs(count, f_nxt, s_nxt, round);\n    }\n        \n    void dfs(int len, int f, int s, int round){\n        if(dp[round][f][s]){return;}\n        \n        if(f == len-1-s){\n            dp[round][f][s] = true;\n            Min = min(Min, round);\n            Max = max(Max, round);\n            return;\n        }\n        \n        perm(len, f, s, round+1, 0 ,len-1, 0);\n        \n    }\npublic:\n    vector<int> earliestAndLatest(int n, int firstPlayer, int secondPlayer) {\n        dfs(n, firstPlayer-1, secondPlayer-1, 1);\n        return vector<int>{Min, Max};\n    }\n};\n```
[]