Very Easy O(N) solution


#1

void Solution::sortColors(vector &A) {
auto itr=A.begin();
map<int,int> m;
for(auto x:A)m[x]++;
auto it=m.begin();
A.erase(itr,A.end());
for(;it!=m.end();it++)
{A.insert(itr,(*it).second,(*it).first);
itr=A.end();}
}