IMohammedNasr

Untitled

Mar 1st, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. void solve()
  2. {
  3. int n;
  4. cin >> n;
  5. vector<int> v(n);
  6. for (auto &i : v)
  7. cin >> i;
  8. sort(v.begin(), v.end());
  9. for (int i = 0; i < n - 1; i++)
  10. {
  11. if (v[i + 1] != v[i] + 1)
  12. {
  13. cout << v[i] + 1 << endl;
  14. return;
  15. }
  16. }
  17. cout << v[0] + 1 << endl;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment