Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<vector>
- #include<map>
- int solution(vector<int> &A) {
- // write your code in C++14 (g++ 6.2.0)
- using namespace std;
- vector<int> Vaux;
- map<int, int> M;
- int result=-1;
- for (int it : A){
- if (M.count(it)!=0) M[it]+=1;
- else if (M.count(it)==0) {
- M[it]=1;
- Vaux.push_back(it);
- }
- }
- for (int it : Vaux){
- if (M[it]==1) {
- result=it;
- break;
- }
- }
- return result;
- }
Add Comment
Please, Sign In to add comment