Skip to content

Commit 2a95f14

Browse files
authored
Merge pull request gzc426#275 from GatesMa/patch-4
Create GatesMa.md
2 parents b9c9eb6 + c5b3b99 commit 2a95f14

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

2018.12.2-leetcode557/GatesMa.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# c++
2+
```cpp
3+
class Solution {
4+
public:
5+
string reverseWords(string s) {
6+
stringstream ss;
7+
string temstr, str;
8+
ss << s;
9+
vector<string> strs;
10+
while(ss){
11+
ss >> temstr;
12+
reverse(temstr.begin(),temstr.end());
13+
strs.push_back(temstr);
14+
}
15+
strs.pop_back();
16+
int len = strs.size();
17+
str += strs[0];
18+
for(int i =1;i < len;i++){
19+
str += " " + strs[i];
20+
}
21+
return str;
22+
}
23+
};
24+
```

0 commit comments

Comments
 (0)