Maximum Occurring Character
Updated
Problem statement
Given a nonempty string text, return the character that occurs most often, as a string of length 1.
If several characters have the same maximum frequency, return the one with the smallest ASCII code. Comparisons are case-sensitive. Spaces and punctuation count as ordinary characters.
Function
maximumOccurringCharacter(text: String) → StringExamples
Example 1
text = "hello"return = "l"The character l appears twice; every other character appears once.
Example 2
text = "bbaa"return = "a"Both characters appear twice. ASCII a is smaller than b.
Constraints
1 <= text.length <= 10^5.- Every character is printable ASCII with a code from
32through126.
More Vanguard Online Assessment questions
- Two SumOA · Seen Sep 2026
- Valid ParenthesesOA · Seen Sep 2026
- Are They PangramsOA · Seen Nov 2025
- Missing WordsOA · Seen Nov 2025
- Spam DetectionOA · Seen Nov 2025
- Binge WatchingOA · Seen Jan 2023
- Minimum Moves Around a Circular ArrayOA · Seen Aug 2022
- Picking TicketsOA · Seen Mar 2022
- Tool List: Two Smallest ValuesOA · Seen Nov 2021
- Group AnagramsOA · Seen Nov 2019
Similar questions at other companies
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- First Non-Repeating CharacterAmazon · OA · ONSITE INTERVIEW
- Total Each Letter's Count in an Encoded StringIBM · OAIBM interview questions
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
- Count Palindrome Addition ChoicesThe D.E. Shaw Group · OAThe D.E. Shaw Group interview questions
- Count Palindrome Addition ChoicesHudson River Trading · OAHudson River Trading interview questions
- Count Phrases Formed by Anagram ReplacementWells Fargo · OAWells Fargo interview questions
- Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
- Branch with the Most FilesCapital One · OACapital One interview questions