Skip to content

Latest commit

 

History

History
13 lines (10 loc) · 543 Bytes

File metadata and controls

13 lines (10 loc) · 543 Bytes

Problem 12: Frequency-Weighted Ordering (Sort Characters By Frequency)

Problem Statement

Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the sorted string. If there are multiple answers, return any of them.

Input Format

  • A string s.

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'.