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

30:00

Length of Last Word
easy
Topics
Companies

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

Example 1:
Input: "Hello World"
Output: 5
Constraints:
  • 1s.length1041 \leq s.\text{length} \leq 10^4

  • s consists of only English letters and spaces ' '.

  • There will be at least one word in s.

Input
arr ="Hello World"

Find last word

s
H0e1l2l3o45W6o7r8l9d10
Variables
VariableValue
sHello World
DepthFunction Call
Stack empty
0/1