Skip to content

Commit d56ad30

Browse files
authored
Merge pull request gzc426#153 from heyheyheyi/master
1
2 parents 752e83f + 1ea6580 commit d56ad30

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

2018.11.28-leetcode151/棕榈树.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class TestReverseWords {
2+
public static String reverseWords(String s){
3+
if(s==null||s.length()==0){
4+
return "";
5+
}
6+
String[] array = s.split(" ");
7+
String str = "";
8+
for(int i=array.length-1;i>=0;i--){
9+
if(!array[i].equals("")){
10+
if(str.length()>0){
11+
str+=" ";
12+
}
13+
str += array[i];
14+
}
15+
}
16+
return str;
17+
}
18+
19+
public static void main(String[] args) {
20+
String s = "hello world!";
21+
System.out.println(reverseWords(s));
22+
}
23+
}

0 commit comments

Comments
 (0)