leetcode [#58] | GCidea's blog
目录1. 题目2. 解决方案3. 注意事项
题目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.
ExampleGiven s = “Hello World”,return 5.
NoteA word is defined as a character sequence consists of non-space characters only.
解决方案1234567891011public class Solution { public int lengthOfLastWord(String s) { if(s == null || s.length() == 0) return 0; String[] arr = s.split(" ")...阅读全文
题目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.
ExampleGiven s = “Hello World”,return 5.
NoteA word is defined as a character sequence consists of non-space characters only.
解决方案1234567891011public class Solution { public int lengthOfLastWord(String s) { if(s == null || s.length() == 0) return 0; String[] arr = s.split(" ")...阅读全文