Problem · String
Character Frequencies in First-Appearance Order
Learn this problemProblem 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.