FunctionRacerProblemsRace

Length of Last Word

EasyStringsPython, JavaScript, TypeScript, Java, C++

Return the number of letters in the last word of s. A word is a run of characters that are not spaces, and s may end with spaces.

Example 1

s "Hello World"
returns 5

The last word is World, which has 5 letters.

Example 2

s " fly me "
returns 2

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 Strings problems