Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Sort Characters by Frequency

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Sort Characters by Frequency. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given a string s, return a new string where characters are grouped and ordered by decreasing frequency. If two characters have the same frequency, any relative order between them is valid.

Constraints

  • 1 <= len(s) <= 5 * 10^5
  • s may contain letters, digits, and symbols
  • Equal frequencies may appear in any order
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output