Character Frequency Problem

Character Frequency Problem — ExecCode Easy DSA Practice

Solve the Character Frequency problem on ExecCode. Free online easy DSA practice in Strings - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a string s, sort it in decreasing order based on the frequency of the characters. Your task is to compute the required answer and return the sorted string. The frequency of a character is the number of times it appears in the string. If there are multiple answers, return any of them.

Examples

Input {"s": "apple", "c": "p"}; Output 2. Input {"s": "banana", "c": "a"}; Output 3. Input {"s": "Mississippi", "c": "s"}; Output 4

Constraints

1 <= s.length <= 5 * 10^5 s consists of uppercase and lowercase English letters and digits.

Practice Character Frequency free on ExecCode. Browse DSA problems, topic map, and placement guides.