✅ Easy C++ Solution
Code\n\nclass Solution {\npublic:\n    string sortString(string s) {\n        map<char,int> mp;\n        string ans = "";\n        int n = s.size();\n        fo
# Code\n```\nclass Solution {\npublic:\n    string sortString(string s) {\n        map<char,int> mp;\n        string ans = "";\n        int n = s.size();\n        for(char ch : s)\n        {\n            mp[ch]++;\n        }\n        int i = 0;\n        bool check = true;\n        while(i < n)\n        {\n            if(check)\n            {\n                for(auto it = mp.begin(); it != mp.end(); it++)\n                {\n                    if(it-> second >= 1)\n                    {\n                        ans += it-> first;\n                        it-> second--;\n                        i++;\n                    }\n                }\n                check = false;\n            }\n            else if(!check)\n            {\n                auto it = mp.end();\n                do\n                {\n                    it--;\n                    if(it-> second >= 1)\n                    {\n                        ans += it-> first;\n                        it-> second--;\n                        i++;\n                    }\n                } while(it != mp.begin());\n                check = true;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']