A string s= tree is given to rearrange in decreasing order of frequency such that, the output will be "eetr" or "eert".
Check the frequency of the characters;
e = 2;
t = 1;
r = 1;
writing this in decreasing order of frequency;
output = eetr
output = eert
Here r and t are of the same frequency, therefore anyone can be written first.
I saved the frequencies in a hashtable.
I sorted them (frequencies) in decreasing order.
I rebuilt the strings based on frequencies.