leetcode557 C++ 56ms 反转字符串中的每个单词
class Solution {
public:
string reverseWords(string s) {
auto st = s.begin();
for(auto i = s.begin();i<s.end();i++){
if(*i == ' '){
reverse(st, i);
st = i + 1;
}
}
reverse(st, s.end());
return s;
}
};