Perfectly answered!


#1
int Solution::lengthOfLastWord(const string s) {
    string word;
    stringstream ss(s);
    int ans=0;
    while(ss>>word){
        ans=word.length();
    }
    return ans;
    
}


#2

Can you explain about the stringstream and what are it’s uses.


#3

Please explain about the ‘stringstream’ which you used in your solution.