FunctionRacerProblemsRace

Most Common Word Length

EasyHash mapsPython, JavaScript, TypeScript, Java, C++

sentence holds lowercase words separated by single spaces. Return the word length that occurs most often among its words.

If several lengths occur equally often, return the smallest of them. The empty sentence has no words and gives 0.

Example 1

sentence "the quick brown fox jumps"
returns 5

Lengths are 3, 5, 5, 3, 5: three words of length 5 and two of length 3.

Example 2

sentence "a bb cc d"
returns 1

Lengths 1 and 2 each occur twice; the smaller length wins.

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