[C++] Solution


  • 0
    A
    class Solution {
    public:
        string reverseWords(string s) {
            
            if(s=="")
                return s;
            istringstream ss(s);
            string a;
            string v="";
            while(ss >> a){
                reverse(a.begin(),a.end());
                v=v+a+" ";
            }
            v.resize(v.size()-1);
            return v;
        }
    };
    
    

Log in to reply
 

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