Given a string, reorder its characters so that characters with higher frequency come first. To keep the answer deterministic, break ties by smaller character code first.
s = input string
string sorted by frequency descending and character ascending on ties
Example 1:
Input:
s = "tree"
Output:
eert
Explanation:
e appears twice, while r and t appear once; r comes before t on the tie.
Example 2:
Input:
s = "cccaaa"
Output:
aaaccc
Explanation:
a and c both appear three times, so a comes first on the tie.