Question: Sort Characters by Frequency. Please use hash table, language doesn't matter. Given a string s , sort it in deceasing order based on the frequency

Sort Characters by Frequency. Please use hash table, language doesn't matter.

Given a string s , sort it in deceasing order based on the frequency of the characters. the frequency of a character is the number of times it appears in the string.

-- Example --

Input: s = "tree"

Output: "eert"

Explanation: e appears twice while r and t both appear once. So e must appear before both r and t.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!