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
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.