Description
Given a string s, sort it in decreasing order based on the frequency of the characters. Characters with same frequency can be in any order.
Examples
Input:
s = "tree"Output:
"eert"Explanation:
e appears twice.
Input:
s = "programming"Output:
"rrggmmainpop"Explanation:
r appears 2 times, g appears 2 times, m appears 2 times. Among characters with frequency 1 (a, i, n, p, o), any order is valid since they have the same frequency.
Input:
s = "a"Output:
"a"Explanation:
Single character string - the character 'a' appears once, so the output is just 'a'.
Constraints
- •
1 ≤ s.length ≤ 5 × 10⁵