Sort Characters By Frequency

easy
1. Given a string, sort it in decreasing order based on the frequency of characters (If frequency is equal then the character which appears first in lexicographical order comes first).

Input Format

First line contains the given string.

Output Format

return the sorted string.

Constraints

size of the string < 1000

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
tree
Output
eert
Previous
Smallest Window In A String Containing All The Characters Of Another String
Next
Sorting Elements Of An Array By Frequency

Related Questions