Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knakul853
- **/
- class Solution {
- public:
- string reverseWords(string s) {
- int n = (int)s.size();
- istringstream in(s);
- s="";
- string word;
- while( in >> word )
- {
- reverse(word.begin(), word.end());
- s+=word + " ";
- }
- int m = s.size();
- return s.substr(0, m-1);
- }
- };
Add Comment
Please, Sign In to add comment