FastPrepSorted Character Frequencies
Problems/Sorted Character Frequencies

Sorted Character Frequencies

Deloitte logoDeloitte● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Deloitte new grad online assessment. The task asks directly for character frequencies in alphabetical order, with the hello example. We limit the input to lowercase English letters and add limits that work in every language. Our version is about 97% the same as the reported question.

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) → String

Examples

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 <= 100000
  • word contains 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

Interview reports that mention this question

  • Deloitte New Grad Tech OA and Interview Questions: 14 Experiences
All Deloitte interview questionsSee Deloitte hiring insights
Saved
class Solution {
    public String sortedCharacterFrequencies(String word) {
        // Write your solution here.
    }
}
Checking account…