Advertisement
Guest User

Sort Characters By Frequency

a guest
Feb 25th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. Given a string, sort it in decreasing order based on the frequency of characters.
  2.  
  3. Example 1:
  4.  
  5. Input:
  6. "tree"
  7.  
  8. Output:
  9. "eert"
  10.  
  11. Explanation:
  12. 'e' appears twice while 'r' and 't' both appear once.
  13. So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement