fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n;
  7. cin >> n;
  8.  
  9. vector<int> nums(n);
  10. vector<int> f(n + 1, 0);
  11.  
  12. // taking input
  13. for (int i = 0; i < n; i++)
  14. {
  15. cin >> nums[i];
  16. }
  17.  
  18. // counting the frequency
  19. for (int i = 0; i < n; i++)
  20. {
  21. f[nums[i]]++;
  22. }
  23.  
  24. for (int i = 0; i < n; i++)
  25. {
  26. if (f[i] == 1)
  27. cout << i << endl;
  28. ;
  29. }
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty