- Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSolution541.java
More file actions
Latest commit
31 lines (27 loc) · 887 Bytes
/
Copy pathSolution541.java
File metadata and controls
31 lines (27 loc) · 887 Bytes
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
30
31
importjava.util.Arrays;
/**
* Created by slade on 2019/12/26.
*/
publicclassSolution541 {
publicStringreverseStr(Strings, intk) {
if (s.length() > 2 * k) {
returnreverseSingle(s.substring(0, 2 * k), k) + reverseStr(s.substring(2 * k), k);
} else {
returnreverseSingle(s, k);
}
}
publicStringreverseSingle(Strings, intk) {
if (s.length() >= k) {
Strings1 = newStringBuffer(s.substring(0, k)).reverse().toString();
Strings2 = s.substring(k).toString();
returns1 + s2;
} else {
Strings1 = newStringBuffer(s).reverse().toString();
returns1;
}
}
publicstaticvoidmain(String[] args) {
Solution541solution541 = newSolution541();
System.out.println(solution541.reverseStr("abcdefg", 2));
}
}