Why is this giving TLE?


#1

vector Solution::solve(vector &A, vector &B, vector &C) {
map<int,int> c;
vector::iterator it;

it = unique(A.begin(), A.end()); 
A.resize(distance(A.begin(), it)); 
it = unique(B.begin(), B.end());
B.resize(distance(B.begin(), it)); 
it = unique(C.begin(), C.end()); 
C.resize(distance(C.begin(), it)); 

for(int i=0;i<A.size();i++){c[A[i]]++;}
for(int i=0;i<B.size();i++){c[B[i]]++;}
for(int i=0;i<C.size();i++){c[C[i]]++;}
vector<int> ans;
for(auto i:c)
{  // cout<<i.first<<i.second<<" ";
    if(i.second>1)ans.push_back(i.first);
    
}return ans;

}