题目描述:
解法:
class Solution {
public:
string frequencySort(string s) {
unordered_map<char, int> ump;
for (const auto& str : s)
ump[str]++;
multimap<int, char,greater<int>> mltmp;
for (auto it : ump)
mltmp.insert({ it.second,it.first });
string res;
for (auto it : mltmp) {
int t = it.first;
while (t--)
res += it.second;
}
return res;
}
};