58. Length of Last Word
Input: "Hello World"
Output: 5解题要点:
class Solution {
public int lengthOfLastWord(String s) {
if(s.length() == 0 || s == null) return 0;
String[] sc = s.split(" ");
if(sc.length == 0) return 0;
return sc[sc.length - 1].length();
}
}Last updated