Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
If the last word does not exist, return 0.
Note: A word is defined as a character sequence consists of non-space characters only.
For example,
Given s = "Hello World",
return 5.
原文链接http://blog.youkuaiyun.com/crazy__chen/article/details/46008555
本文介绍了一种通过遍历字符串并检查空格来确定最后一个单词长度的方法。提供了一个Java实现示例,该示例从字符串末尾向前遍历,跳过尾部空格并计算最后一个非空格字符序列的长度。
169

被折叠的 条评论
为什么被折叠?



