Problem
A string s holds words separated by spaces. There may be extra spaces at the start, at the end, or between words. A word is a run of non-space characters with no space inside it. Return the length of the last word in s.
Example 1
- Input
- s = "the quick fox"
- Output
- 3
- Why
- "fox"
Example 2
- Input
- s = " hold the line "
- Output
- 4
- Why
- "line"
Example 3
- Input
- s = "a"
- Output
- 1
Constraints
1 <= s.length <= 10^4s contains only English letters and spaces.s contains at least one word.