Skip to content

Commit d2e2413

Browse files
authored
Merge pull request gzc426#6 from a-yin/a-yin-patch-4
Create 湛江甲鸟.md
2 parents 74f8342 + bb55ee9 commit d2e2413

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
```
2+
public static String reverseWords(String s) {
3+
int len = s.length();
4+
int j = len;
5+
String result = "";
6+
for (int i = len - 1; i >= 0; i--) {
7+
if (s.charAt(i) == ' '){
8+
j = i ;
9+
} else if (i == 0 || s.charAt(i - 1) == ' ') {
10+
if (result.length() != 0) {
11+
result += ' ';
12+
}
13+
result += s.substring(i, j);
14+
}
15+
}
16+
return result;
17+
}

0 commit comments

Comments
 (0)