Warm-ups · 16 of 24
Frequency of each character
Return "char:count" for every distinct character, in the order each character first appears.
Examples
Input s = "banana"
Output ["b:1", "a:3", "n:2"]
Input s = "aAa"
Output ["a:2", "A:1"]
Upper and lower case are different characters.
📘 New to this? Counting with a hash map explains the idea in a few minutes.