Given a string s consisting of words and spaces, return the length of the last word in the string.

A word is a maximal substring consisting of non-space characters only.

Example 1:

  • Input: s = โ€œHello Worldโ€
  • Output: 5
  • Explanation: The last word is โ€œWorldโ€ with length 5.

Example 2:

  • Input: s = โ€œ fly me to the moon โ€œ
  • Output: 4
  • Explanation: The last word is โ€œmoonโ€ with length 4.

Example 3:

  • Input: s = โ€œluffy is still joyboyโ€
  • Output: 6
  • Explanation: The last word is โ€œjoyboyโ€ with length 6.

Constraints:

  • 1 <= s.length <= 104
  • s consists of only English letters and spaces โ€˜ โ€˜.
  • There will be at least one word in s.