BEST answer here(using stringstream)


#1

int Solution::lengthOfLastWord(const string A) {
stringstream ss(A);string x;
while(ss>>x);
return x.length();

}