simplicity in code > infinity
\'\'\'class Solution {\npublic:\n    int earliest = INT_MAX;\n    int latest = INT_MIN;\n    vector earliestAndLatest(int n, int first, int second) {\n        b
\'\'\'class Solution {\npublic:\n    int earliest = INT_MAX;\n    int latest = INT_MIN;\n    vector<int> earliestAndLatest(int n, int first, int second) {\n        bool visit[n];\n        memset(visit,true,sizeof(visit));\n        solve(first-1,second-1,1,0,n-1,visit,n);\n        vector<int> vec = {earliest,latest};\n        return vec;\n    }\n    void solve(int first,int second,int round,int i,int j,bool visit[],int n)\n    {\n              while(i < n && visit[i] != true)       \n              i++;\n              while(j >= 0 && visit[j] != true)\n              j--;\n              if(i >= j){ \n                solve(first,second,round+1,0,n-1,visit,n);\n                return;\n              }\n             if(i == first && j == second)\n             {\n              earliest = min(earliest,round);\n              latest = max(latest,round);   \n              return;\n             }\n             else if(i == first || i == second)\n             {\n                visit[j] = false;\n                solve(first,second,round,i+1,j-1,visit,n);\n                visit[j] = true;\n             }\n             else if(j == first || j == second)\n             {\n                visit[i] = false;\n                solve(first,second,round,i+1,j-1,visit,n);\n                visit[i] = true;\n             }\n             else\n             {\n                 visit[j] = false;\n                 solve(first,second,round,i+1,j-1,visit,n);\n                 visit[j] = true;\n                 visit[i] = false;\n                 solve(first,second,round,i+1,j-1,visit,n);\n                 visit[i] = true;\n             } \n    }\n    \n    \n};
[]