STL-- unordered_map
序列中整数去重
http://www.nowcoder.com/questionTerminal/6564a2f6e70f4153ad1ffd58b2b28490
遇到题就想着用STL ,别说还挺爽
#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
int main()
{
int n; cin >> n;
vector<int> vec;
unordered_map<int,int> hash;
for(int i=0;i<n;i++)
{
int x; cin >> x;
vec.push_back(x);
hash[x] ++;
if(hash[x] >= 2) vec.pop_back();
}
for(int i=0;i<vec.size();i++)
cout << vec[i] << " ";
return 0;
}