FunctionRacerProblemsRace

Letter Count Table

BeginnerHash mapsPython, JavaScript, TypeScript, Java, C++

text is a string of lowercase letters. Build a table of letter counts: return a dictionary that maps every letter that appears in text to the number of times it appears.

Only letters that actually appear may be keys. The empty string gives an empty dictionary.

Example 1

text "banana"
returns {"b":1,"a":3,"n":2}

b appears once, a three times and n twice.

Example 2

text "abc"
returns {"a":1,"b":1,"c":1}

Every letter of abc appears exactly once.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Hash maps problems