Easy solution using map in C++. Rbb


#1
void Solution::sortColors(vector<int> &A) {
map<int,int> mp;
for (auto i: A)
{
    mp[i]++;
}
vector<int> ans;
for(auto i: mp)
{
    while(i.second!=0)
    {
        ans.push_back(i.first);
        i.second-=1;
    }
}
A=ans;

}