4 lines simple c++ solution. Do u guys think that I am cheating?


  • 0
    G
    
    class Solution {
    public:
        int lengthOfLastWord(string s) {
            stringstream ss(s);
            string sol;
            while(ss >> sol);
            return sol.size();
        }
    };
    

Log in to reply
 

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