fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. unordered_map <int, int> hm;
  4. int main()
  5. {
  6. int n; cin >> n; int a[n];
  7. for(int i=0; i<n; i++)
  8. {
  9. cin >> a[i];
  10. hm[a[i]]++;
  11. }
  12. int *arr= new int, index=0;
  13. for(auto it=hm.begin(); it!=hm.end(); it++)
  14. {
  15. if(it->second==1)
  16. {
  17. arr[index++]=it->first;
  18. }
  19. }
  20. for(int i=index-1; i>=0; i--) cout << arr[i] << " ";
  21. }
Success #stdin #stdout 0s 15240KB
stdin
9
1 2 3 4 5 6 7 8 9
stdout
4 0 4113 1 5 6 7 8 9