Length of the last word
A string s is made of English letters and spaces. A word is a stretch of letters side by side, with a space or an end of s on each side: in "big data" the words are big and data, and dat is not a word. Spaces can sit at the start, at the end, or several in a row.
Return the number of letters in the last word of s. There is always at least one word.
s = "load the table "Output5The last word is table. The two spaces after it are not a word.
s = " sort merge join"Output4The two spaces at the start and the three between sort and merge change nothing: the last word is join.
s = "a"Output1One word of one letter, starting at position 0.
1 ≤ len(s) ≤ 104
Every character is an English letter or a space.
At least one character is a letter.
Plan it first
Write a line for each before you code, then say them out loud. Compare with the Approach tab afterwards.