Length of Last Word
Easy
Strings
String
Given a string of words separated by spaces, return the length of the last word.
Constraints
1 ≤ s.length ≤ 10^4
Examples
Example 1:
Input: Hello World
Output: 5
Example 2:
Input: fly me to the moon
Output: 4
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console