4ms 4-line stringstream c++ solution


  • 0
    A
    int lengthOfLastWord(string s) {
        stringstream ss(s);
        string word;
        while(ss >> word);
        return word.length();  
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.