Skip to content

Commit

Permalink
completed
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Oct 8, 2018
1 parent 89333dc commit 34ec304
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lc151. Reverse Words in a String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ class Solution {
i++;
}
s.erase(s.begin(),s.begin()+i);
// 不应用索引,应该用迭代器
i=0;
while(i<s.size()){


while(i<s.size()&&!isalnum(s[i])){
while(i<s.size()&&s[i]==' '){
i++;
}
j=i;
while(j!=s.size()&&isalnum(s[j])){
while(j!=s.size()&&s[j]!=' '){
j++;
}
reverse(s.begin()+i,s.begin()+j);
Expand Down

0 comments on commit 34ec304

Please sign in to comment.