Skip to content

Commit d417d4e

Browse files
authored
Merge pull request gzc426#237 from Ostrichcrab/master
`
2 parents a41c39a + 6cadcac commit d417d4e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

2018.12.2-leetcode557/Ostrichcrab.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
```
2+
class Solution {
3+
public:
4+
string reverseWords(string s) {
5+
s+=" ";
6+
int len = s.length();
7+
int left = 0, right = 0;
8+
for(int i = 0; i < len; i++){
9+
while(s[i]!=' ') right++,i++;
10+
reverse(s.begin()+left,s.begin()+right);
11+
right++;
12+
left=right;
13+
}
14+
s.pop_back();
15+
cout<<s<<endl;
16+
return s;
17+
}
18+
};
19+
```

0 commit comments

Comments
 (0)