Randomised Solution.
define ll long long\n#define pb push_back\n#define vl vector\n#define all(x) x.begin(),x.end()\n\nclass Solution {\npublic:\n    vector earliestAndLatest(int n,
#define ll long long\n#define pb push_back\n#define vl vector<ll>\n#define all(x) x.begin(),x.end()\n\nclass Solution {\npublic:\n    vector<int> earliestAndLatest(int n, int s1, int s2) {\n          ll mn = 1e9, mx = 0;\n\n  ll t = 1000;\n\n  while (t--) {\n\n\n    vl v;\n    for (ll i = 1; i <= n; i++)v.pb(i);\n\n    ll flag = 0;\n\n    for (int i = 0; i < 7; i++) {\n      ll n1 = v.size();\n      vl new_v;\n      // for (auto d : v)cout << d << " ";\n      // cout << endl;\n      for (ll j = 0; j < n1; j++) {\n        // j vs n1-j-1;\n        if (j > n1 - j - 1)break;\n        if (j == n1 - j - 1)new_v.pb(v[j]);\n        else {\n          ll p1 = v[j], p2 = v[n1 - j - 1];\n          if (p1 == s1 && p2 == s2) {\n            mn = min(mn, i + 1ll);\n            mx = max(mx, i + 1ll);\n            flag = 1;\n            break;\n          } else if (p1 == s1) {\n            new_v.pb(p1);\n          } else if (p1 == s2) {\n            new_v.pb(p1);\n          } else if (p2 == s1) {\n            new_v.pb(p2);\n          } else if (p2 == s2) {\n            new_v.pb(p2);\n          } else {\n            ll dec = rand()%100;\n            if (dec & 1)new_v.pb(p2);\n            else new_v.pb(p1);\n          }\n        }\n      }\n      if (flag)break;\n      sort(all(new_v));\n      v = new_v;\n    }\n\n  }\n        return {(int)mn,(int)mx};\n    }\n};
['C']