Skip to content

Commit

Permalink
简单的反转单词
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Oct 7, 2018
1 parent e9e3f91 commit 89333dc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lc557. Reverse Words in a String III.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution {
public:
string reverseWords(string s) {
auto i=s.begin(),j=s.begin();
while(i!=s.end()){


while(j!=s.end()&&((*j)!=' ')){
j++;
}
reverse(i,j);
if(j==s.end()){
break;
}
i=++j;

}
// reverse(s.begin(),s.end());
return s;
}
};

0 comments on commit 89333dc

Please sign in to comment.