class Solution {
public:
int lengthOfLastWord(string s) {
if(s.size()==0)return 0;
stringstream ss(s);
int lastlen=0;
string temp;
while(getline(ss,temp,' '))
{
if(temp.size()!=0)
lastlen=temp.size();
}
return lastlen;
}
};
58. Length of Last Wor
最新推荐文章于 2018-03-07 19:20:47 发布