Skip to content

Commit 80103a8

Browse files
authored
557.txt
leetcode 557
1 parent 4f47f39 commit 80103a8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

2018.12.2-leetcode557/557.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
public class Main557 {
2+
public static void main(String[] args){
3+
Main557 main = new Main557();
4+
main.test();
5+
}
6+
7+
public void test(){
8+
System.out.println(reverseWords("Let's take LeetCode contest"));
9+
}
10+
11+
public String reverseWords(String s) {
12+
String[] sArr = s.split("\\s+");
13+
StringBuilder sb = new StringBuilder();
14+
for (String arr:sArr){
15+
char[] chars = arr.toCharArray();
16+
for (int i = chars.length-1;i>=0;i--){
17+
sb.append(chars[i]);
18+
}
19+
sb.append(" ");
20+
}
21+
return sb.toString().trim();
22+
}
23+
24+
25+
}

0 commit comments

Comments
 (0)