Example 1lengthOfLastWord()InputCopys = "Hello World"OutputCopy5WhyThe last word is "World" with length 5.
Example 2lengthOfLastWord()InputCopys = " fly me to the moon "OutputCopy4WhyThe last word is "moon" with length 4.