1. Description
2. Solution
代码语言:javascript复制class Solution {
public:
int lengthOfLastWord(string s) {
int length = 0;
int index = s.find_last_not_of(" ");
if(index == -1) {
return length;
}
while(index >= 0 && s[index--] != ' ') {
length ;
}
return length;
}
};