C++ using sstream


  • 0
    F
    class Solution {
    public:
        int countSegments(string s) {
            int count = 0;
            stringstream str;
            str << s;
            while(str >> s)
                count ++;
            return count;
        }
    };
    

Log in to reply
 

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