We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c417eb5 + 949a80f commit d283e51Copy full SHA for d283e51
2018.11.28-leetcode151/WhiteNight.md
@@ -0,0 +1,33 @@
1
+```java
2
+/**
3
+ * 翻转字符串里面的单词
4
+ *
5
+ */
6
+public class S2 {
7
+ public String reverseWords(String s) {
8
+ if (s == null || s.length() == 0)
9
+ return "";
10
+
11
+ String[] string = s.split(" ");
12
+ String res = "";
13
14
+ for (int i = string.length - 1; i >= 0; i--) {
15
+ if (!string[i].equals("")){
16
+ if (res.length() > 0){
17
+ res += " ";
18
+ }
19
+ res += string[i];
20
21
22
23
+ return res;
24
25
26
+ public static void main(String[] args) {
27
+ S2 s = new S2();
28
+ String string = "the sky is blue";
29
+ String res = s.reverseWords(string);
30
+ System.out.println(res);
31
32
+}
33
+```
0 commit comments