C++ using string stream


  • 0
    Q

    string reverseWords(string s) {
    string result;
    stringstream ss(s);
    while(ss>>s)
    {
    reverse(s.begin(),s.end());
    result+=s;
    result+=" ";
    }
    result.pop_back();
    return result;
    }


Log in to reply
 

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