C++ Solution using(push_back)->TLE and not using(push_back)376ms
Way1 -> not use push_back\n\nclass Solution {\npublic:\n    unordered_set<long long>memo;\n    int firstPlayer,secondPlayer,mn,mx;\n    void helper(vector<int>&
Way1 -> not use push_back\n```\nclass Solution {\npublic:\n    unordered_set<long long>memo;\n    int firstPlayer,secondPlayer,mn,mx;\n    void helper(vector<int>& arr,int round)\n    {\n        int n=arr.size();\n        long long mod=1e9+7;\n        long long now=0;\n        for(auto &x:arr)\n        {\n            now*=10;\n            now+=x;\n            now%=mod;\n        }\n        if(memo.find(now)!=memo.end())return;\n        memo.insert(now);\n        int size=arr.size()/2;\n        for(int i=0;i<size;i++)\n            if(arr[i]==firstPlayer && arr[arr.size()-1-i]==secondPlayer)\n            {\n                mn=min(mn,round);\n                mx=max(mx,round);\n                return;\n            }\n        vector<int>next(size+(arr.size()%2==1));  //Difference!!!!!!\n        for(int i=0;i<(1<<size);i++)\n        {\n            int left=0,right=next.size()-1;\n            bool valid=true;\n            for(int j=0;j<size;j++)\n            {\n                if(((i>>j)&1)&&(arr[n-1-j]==firstPlayer||arr[n-1-j]==secondPlayer))\n                {\n                    valid=false;\n                    break;\n                }\n                if((((i>>j)&1)==0)&&(arr[j]==firstPlayer||arr[j]==secondPlayer))\n                {\n                    valid=false;\n                    break;\n                }\n                if((i>>j)&1)next[left++]=arr[j];\n                else next[right--]=arr[arr.size()-1-j];\n            }\n            if(valid==false)continue;\n            if(arr.size()%2==1)next[left]=arr[size];\n            helper(next,round+1);\n        }\n        return;\n    }\n    vector<int> earliestAndLatest(int n, int firstPlayer, int secondPlayer) {\n        this->firstPlayer=firstPlayer;\n        this->secondPlayer=secondPlayer;\n        mn=INT_MAX;\n        mx=INT_MIN;\n        vector<int>arr;\n        for(int i=1;i<=n;i++)arr.push_back(i);\n        helper(arr,1);\n        return {mn,mx};\n    }\n};\n```\nWay2 -> use push_back\n```\nclass Solution {\npublic:\n    int firstPlayer,secondPlayer,mn,mx;\n    unordered_set<long long>memo;\n    void helper(vector<int>& arr,int round)\n    {\n        long long s=0;\n        long long m=1e9+7;\n        for(auto &x:arr)\n        {\n            s*=10;\n            s+=x;\n            s%=m;\n        }\n        if(memo.find(s)!=memo.end())return;\n        memo.insert(s);\n        int n=arr.size();\n        for(int i=0;i<n/2;i++)\n            if(arr[i]==firstPlayer&&arr[n-1-i]==secondPlayer)\n            {\n                mn=min(mn,round);\n                mx=max(mx,round);\n                return;\n            }\n        for(int i=0;i<(1<<(n/2));i++)\n        {\n            vector<int>next; //Difference!!!!!!\n            bool valid=true;\n            for(int j=0;j<n/2;j++)\n            {\n                if(((i>>j)&1)&&(arr[n-1-j]==firstPlayer||arr[n-1-j]==secondPlayer))\n                {\n                    valid=false;\n                    break;\n                }\n                if((((i>>j)&1)==0)&&(arr[j]==firstPlayer||arr[j]==secondPlayer))\n                {\n                    valid=false;\n                    break;\n                }\n                if((i>>j)&1)next.push_back(arr[j]);\n                else next.push_back(arr[n-1-j]);\n            }\n            if(valid==false)continue;\n            if(n%2==1)next.push_back(arr[n/2]);\n            sort(next.begin(),next.end());\n            helper(next,round+1);\n        }\n        return;\n    }\n    vector<int> earliestAndLatest(int n, int firstPlayer, int secondPlayer) {\n        this->firstPlayer=firstPlayer;\n        this->secondPlayer=secondPlayer;\n        mn=INT_MAX;\n        mx=INT_MIN;\n        vector<int>arr;\n        for(int i=1;i<=n;i++)arr.push_back(i);\n        helper(arr,1);\n        return {mn,mx};\n    }\n};\n```
[]