Character Frequencies in First-Appearance Order
Updated
Problem statement
Count the letters in text after ignoring spaces and converting every letter to lowercase.
Return one string for each distinct letter in the order of its first appearance. Format every entry as letter:count.
Function
orderedCharacterFrequencies(text: String) → String[]Examples
Example 1
text = "Amount Characters"return = ["a:3","m:1","o:1","u:1","n:1","t:2","c:2","h:1","r:2","e:1","s:1"]The first distinct letters are a, m, o, u, n, t, c, h, r, e, and s.
Example 2
text = "A b A"return = ["a:2","b:1"]Case and spaces are ignored, while a remains the first distinct letter.
Constraints
1 <= text.length <= 200000textcontains English letters and spaces.textcontains at least one letter.
More Epic Online Assessment questions
Similar questions at other companies
- Branch with the Most FilesCapital One · OACapital One interview questions
- 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