-
-
Notifications
You must be signed in to change notification settings - Fork 299
/
344.java
29 lines (26 loc) · 902 Bytes
/
344.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
__________________________________________________________________________________________________
sample 1 ms submission
class Solution {
public void reverseString(char[] s) {
char[] tmp=new char[s.length];
for(int i=0;i<s.length;i++){
int a=s.length-i-1;
tmp[i]=s[a];
}
for(int i=0;i<tmp.length;i++){
s[i]=tmp[i];
}
}
}
__________________________________________________________________________________________________
sample 40316 kb submission
class Solution {
public void reverseString(char[] s) {
for (int i = 0; i < s.length / 2; i++) {
char temp = s[i];
s[i] = s[s.length - 1 - i];
s[s.length - 1 - i] = temp;
}
}
}
__________________________________________________________________________________________________