4 line clean C++ code using istringstream


  • 0
    C
    class Solution {
    public:
    	int lengthOfLastWord(string s) {
    		string temp;
    		istringstream strcin(s);
    		while (strcin >> temp);
    		return temp.size();
    	}
    };

Log in to reply
 

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