Inscription Leetcode brush (14) - length of the last word of a

Topic Description:

Given a string that contains only lowercase letters and spaces '' returns the length of the last word.

If the last word does not exist, 0 is returned.

Description: A word is defined by letters, but does not contain any spaces of a string

answer:

The first reaction is to see the title split a string! Therefore, direct use of the Spilled () method, need to be determined for an array of strings after division, if the word is not directly returns 0, otherwise return a string length of the last value in the string array.

 

Guess you like

Origin www.cnblogs.com/wangjm63/p/11514936.html