ID Forgery has been a prevalent issue in the city of Einstakt, especially in bars. You are currently working in a government agency that tries to identify individuals sharing the same ID numbers and perform a formal investigation. Each day, your team travels to two random bars to collect the encoded IDs of each bar patron.
Please read instructions and complete in C++. Show functions. Confused.


void find_duplicates( vector<string> input ) {
int i,j,n = input.size();
map<string,int> m;
for(i=0;i<n;i++)
{
if(input[i]=="Bar1" || input[i]=="Bar2")
continue;
string tmp = input[i];
string ans = "";
for(j=0;j<tmp.length();j++)
{
if(tmp[j]!='(')
{
ans+=tmp[j];
continue;
}
else { j++;
string tt = "";
while(tmp[j]!=')')
{
tt+=tmp[j];
j++;
}
reverse(tt.begin(),tt.end());
ans+=tt;
j++;
m[ans]++;
}
}
}
vector<string> innocent,duplicate;
for(auto ite =m.begin();ite!=m.end();ite++)
{
if(ite->second == 1)
{
innocent.push_back(ite->first);
}
else {
duplicate.push_back(ite->first);
}
}
sort(innocent.begin(),innocent.end());
sort(duplicate.begin(),duplicate.end());
cout<<"Innocent:\n";
for(i=0;i<innocent.size();i++)
cout<<innocent[i]<<"\n";
cout<<"Duplicate\n";
for(i=0;i<duplicate.size();i++)
cout<<duplicate[i]<<"\n";
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps









