You are viewing a single comment's thread. Return to all comments →
I cann't figure out what am I doing wrong
int makeAnagram(string a, string b) { map mp;
int n = a.size(), m = b.size(); for(int i=0; i<n; i++){ if(mp.count(a[i])) mp[a[i]]++; else mp[a[i]] =1; } for(int i=0; i<m; i++){ if(mp.count(b[i])) mp[b[i]]--; else { mp[b[i]] =1; } } map<char, int>:: iterator it; int cot = 0; for(it=mp.begin(); it!=mp.end(); ++it){ cot+= (0<it->second)?it->second:(-it->second); } return cot;
}
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
I cann't figure out what am I doing wrong
int makeAnagram(string a, string b) { map mp;
}