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 2d776f0 + a2af90b commit 9d8088aCopy full SHA for 9d8088a
2018.12.2-leetcode557/。。。.md
@@ -0,0 +1,16 @@
1
+ public String reverseWords(String s) {
2
+ char[] chars = s.toCharArray();
3
+ int len = 0;
4
+ for (int i = 0; i <= chars.length; i++){
5
+ if (i == chars.length || chars[i] == ' '){
6
+ for (int j = i-len-1; j >= 1; j-=2){
7
+ char temp = chars[len];
8
+ chars[len] = chars[len+j];
9
+ chars[len+j] = temp;
10
+ len++;
11
+ }
12
+ len = i+1;
13
14
15
+ return new String(chars);
16
0 commit comments