Sorted Character Frequencies
Updated
Problem statement
You are given a lowercase English word word. Count how many times each distinct character occurs.
Return one string formed by listing the distinct characters in ascending alphabetical order, immediately followed by each character's decimal frequency.
Function
sortedCharacterFrequencies(word: String) → StringExamples
Example 1
word = "hello"return = "e1h1l2o1"The distinct letters are e, h, l, and o in alphabetical order, with frequencies 1, 1, 2, and 1.
Example 2
word = "zzzaabb"return = "a2b2z3"Alphabetical ordering places a and b before z.
Example 3
word = "aaaaaaaaaaaa"return = "a12"A frequency may contain more than one decimal digit.
Constraints
1 <= word.length <= 100000wordcontains only lowercase English letters.
More Deloitte Online Assessment questions
- Seventh Nearest PalindromeOA · Seen May 2026
- Minimum Deletions for a Non-PalindromeOA · Seen Jul 2025
- Minimum-Cost Solar Rooftop AllocationOA · Seen Jul 2025
- Pair Elements with Even SumsOA · Seen Jul 2025
- Count Divisible PermutationsOA · Seen Jan 2025
- Largest Element in an ArrayOA · Seen Nov 2024
- Install Carbon FiltersOA · Seen Oct 2023
- Longest Substring with Even OccurrencesOA · Seen Oct 2023
- Maximum Sum RectangleOA · Seen Apr 2022
- Annual Bank Balance with Monthly Card FeesOA · Seen Jan 2022
Similar questions at other companies
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
- Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
- Flat JSON Value DifferencesChubb · OAChubb interview questions
- Get Search ResultsJP Morgan Chase · OAJP Morgan Chase interview questions
- Lexicographic Word FrequenciesUpstart · OAUpstart interview questions
- Email Log Processing, Grouping, and SortingStripe · OAStripe interview questions
- Most Frequent CharacterMicrosoft · OAMicrosoft interview questions
- Get Maximum Information GainAmazon · OA
- Better CompressionGoldman Sachs · OAGoldman Sachs interview questions