C++ || Explained || Easy || Hash map
\nclass Solution {\npublic:\n    string sortString(string s) {\n        \n        map<char,int> m;  // to store the frequency of character        \n        int 
```\nclass Solution {\npublic:\n    string sortString(string s) {\n        \n        map<char,int> m;  // to store the frequency of character        \n        int count=0; // to count total  number of character or we can use s.size()\n        \n        //store the values in map         \n        for(auto i:s){\n            m[i]++;\n            count++;\n        }\n   \n        \n        string ans=""; // ans to return\n        while(count){\n            \n            // increasing order\n            for(auto i:m){\n                if(i.second!=0 && count!=0){\n                    m[i.first]--;\n                    ans+=i.first;   //add character to ans \n                    count--;\n                }\n            }\n            \n            // decreasing order\n            for(auto it=m.rbegin();it!=m.rend();it++){\n                if(it->second!=0 && count!=0){\n                    m[it->first]--;\n                    ans+=it->first; // add character to ans\n                    count--;\n                }\n            }\n        }\n        return ans; // return final ans\n    }\n    \n};\n```\n**Please Upvote**
['C', 'C++']