Leetcode Daily Question
2.45K subscribers
517 files
2.16K links
Why are you asking me to do Leetcode for this CSS job?
Download Telegram
Leetcode 2021-07-03
🟡 451.sort-characters-by-frequency

🏷️ Tags
#hash_table #string #bucket_sort #counting #sorting #heap_priority_queue

Description
Given a string s, sort it in decreasing order based on the frequency of characters, and return the sorted 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'. Therefore "eetr" is also a valid answer.
Leetcode-cn.com 2021-07-03
🟡 451.sort-characters-by-frequency

🏷️ Tags
#hash_table #string #bucket_sort #counting #sorting #heap_priority_queue

Description
给定一个字符串,请将字符串里的字符按照出现的频率降序排列。

Example
输入:
"tree"

输出:
"eert"

解释:
'e'出现两次,'r'和't'都只出现一次。
因此'e'必须出现在'r'和't'之前。此外,"eetr"也是一个有效的答案。