You are given a string s.
Count how many times each character appears in the string, then rearrange the characters so that characters with higher frequency appear before characters with lower frequency.
If multiple characters have the same frequency, their relative order does not matter.
Uppercase and lowercase letters are considered different.
Return the resultant string.
Input: s = "banana"
Output: "aaannb"
Explanation:
'a' appears 3 times, 'n' appears 2 times, 'b' appears onc
Input: s = "xyz"
Output: "xyz"
Explanation:
All characters appear once, so any ordering is valid.
Input: s = "bbAa"
Output: "bbAa"
Explanation:
'b' appears 2 times, 'A' and 'a' appear once each. Case-sensitive characters are treated separately.
Accepted:
Submission: