C++ BITMASKS  | RECURSIVE
-> Consider all possiblites on both sides of the current array.\n-> Notice we only need half the array size for full information\n-> So complexity would be O(2^
-> Consider all possiblites on both sides of the current array.\n-> Notice we only need half the array size for full information\n-> So complexity would be O(2^(n/2)*n)\n\n\n```\nclass Solution {\npublic:\n    int lm,hm;\n    void solve(set<int> &now,int round,int fp,int sp){\n       \n        if(!now.count(fp) or !now.count(sp))\n            return;\n        \n        int n = (int)(now.size())/2;\n        vector<int> cur_set(now.begin(),now.end());\n        \n        int nn = (int)now.size();\n        \n        for(int mask=0;mask<(1<<n);++mask){\n            set<int> send;\n            if((nn%2)!=0)\n                send.insert(cur_set[n]);\n            bool ok = false;\n            for(int j=0;j<n;j++){\n                int p1 = cur_set[j];\n                int p2 = cur_set[(int)cur_set.size() - 1 - j];\n                if(p1==fp and p2==sp){\n                    lm = min(lm,round);\n                    hm = max(hm,round);\n                    ok=true;\n                    break;\n                }\n                if(p1==fp or p1==sp)\n                    send.insert(p1);\n                else if(p2==fp or p2==sp)\n                    send.insert(p2);\n                else if(mask&(1<<j))\n                    send.insert(p1);\n                else if(!(mask&(1<<j)))\n                    send.insert(p2);\n            }\n            if(!ok){\n                solve(send,round+1,fp,sp);\n            }\n            \n        }\n        \n    }\n    vector<int> earliestAndLatest(int n, int firstPlayer, int secondPlayer) {\n        lm = 2e9;\n        hm = 0;\n        set<int> now;\n        for(int i=1;i<=n;i++)\n            now.insert(i);\n        solve(now,1,firstPlayer,secondPlayer);\n        vector<int> v;\n        v.push_back(lm);\n        v.push_back(hm);\n        return v;\n        \n    }\n};\n```
[]