public class Solution {
public int lengthOfLastWord(String s) {
int length = 0;
for (int i=s.length()-1; i>=0; i--){
if (s.charAt(i) != ' '){
length++;
}else{
if (length>0){
return length;
}
}
}
return length;
}
}
Length of Last Word
最新推荐文章于 2014-11-06 13:32:07 发布