Why partially correct?


#1

vector Solution::solve(vector &A, vector &B, vector &C) {
vectorvt;
map<int,int>mp;
for(int i = 0;i<A.size();i++)
{
if(i>0&&A[i]!=A[i-1])
mp[A[i]] = 1;
if(i==0)
mp[A[i]] = 1;
}
for(int i = 0;i<B.size();i++)
{
if(mp.find(B[i])!=mp.end())
{
if(mp[B[i]]==1)
{
vt.push_back(B[i]);
mp[B[i]] =0;
}
}
else if(i>0&&B[i]!=B[i-1])
mp[B[i]]=1;
else if(i==0)
mp[B[i]]=1;
}
for(int i = 0;i<C.size();i++)
{
if(mp.find(C[i])!=mp.end())
{
if(mp[C[i]]==1)
{
vt.push_back(C[i]);
mp[C[i]] =0;
}
}
}
sort(vt.begin(),vt.end());
return vt;
}


#2

You have to sort the given vectors first. They haven’t mentioned that the given arrays are sorted.