istringstream C++ so easy


  • 1
    B
    class Solution {
    public:
        void reverseWords(string &s) {
            istringstream ss(s);
            string temp;
            string ret;
            while(ss >> temp)
            {
                ret = temp + " " + ret;
            }
            s = ret.substr(0,ret.size()-1);
        }
    };
    

  • 0
    F

    I like this post, good for you!


Log in to reply
 

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