Tap here to switch tabs
Problem
Submissions

Problem: Length of Last Word

med
30 min
Try to solve the Length of Last Word problem.

Statement

Given a string s made up of English letters and space characters, return the length of the last word in s. A word is a maximal contiguous sequence of English letters. Trailing spaces in s should not be considered part of the last word.

Note: s is guaranteed to contain at least one word.

Constraints:

  • 1≤1 \leq s.length ≤104\leq 10^4

  • s consists of only English letters and spaces ' '

  • There will be at least one word in s

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Length of Last Word

med
30 min
Try to solve the Length of Last Word problem.

Statement

Given a string s made up of English letters and space characters, return the length of the last word in s. A word is a maximal contiguous sequence of English letters. Trailing spaces in s should not be considered part of the last word.

Note: s is guaranteed to contain at least one word.

Constraints:

  • 1≤1 \leq s.length ≤104\leq 10^4

  • s consists of only English letters and spaces ' '

  • There will be at least one word in s