C++ Counts
cpp\nstring sortString(string s, string res = "") {\n    int cnt[26] = {};\n    for (auto ch: s)\n        ++cnt[ch - \'a\'];\n    while (s.size() != res.size())
```cpp\nstring sortString(string s, string res = "") {\n    int cnt[26] = {};\n    for (auto ch: s)\n        ++cnt[ch - \'a\'];\n    while (s.size() != res.size()) {\n        for (auto i = 0; i < 26; ++i)\n            res += string(--cnt[i] >= 0 ? 1 : 0, \'a\' + i); \n        for (int i = 25; i >=0; --i)\n            res += string(--cnt[i] >= 0 ? 1 : 0, \'a\' + i);          \n    }\n    return res;\n}\n```
[]