string reverseWords(string s) {
int l=0;
int r=0;
for(int i=0;i<s.length();i++){
if(s[i]==' '){
r=i-1;
while(l<r){
swap(s[l],s[r]);
l++;
r--;
}
l=i+1;
}
if(i==s.length()-1){
r=i;
while(l<r){
swap(s[l],s[r]);
l++;
r--;
}
}
}
return s;
}
标签:int,LC344,string,reverseWords
From: https://www.cnblogs.com/lwx11111/p/16649444.html