Interview Bootcamp
0% completed
Sort Characters By Frequency (easy)
Problem Statement
Given a string, arrange its characters in descending order based on the frequency of each character. If two characters have the same frequency, their relative order in the output string can be arbitrary.
Example
- Input: s = "trersesess"
- Expected Output: "sssseeerrt"
- Justification: The character
sappears four times,ethree times,rtwo times andtonly once. All characters are sorted based on their frequnecy.
- Input: s = "banana"
- Expected Output: "aaannb".
.....
.....
.....
Like the course? Get enrolled and start learning!
Brandon W
· 2 years ago
I think difficulty for this problem needs reexamining, because on LeetCode this is marked as a Medium NOT an easy. Definitely made me feel better when I wasn't immediately getting it knowing it was harder than what it says.
Show 2 replies