class Solution {
public String solution(String my_string, int s, int e) {
StringBuilder sb = new StringBuilder(my_string);
String tmp = sb.substring(s, e+1);
String reversed = new StringBuilder(tmp).reverse().toString();
return my_string.substring(0, s) + reversed + my_string.substring(e+1);
}
}
.reverse()는 StringBuilder 에서만 사용 가능
[다른 사람의 풀이]
class Solution {
public String solution(String my_string, int s, int e) {
StringBuilder answer = new StringBuilder(my_string.substring(s, e + 1));
answer.reverse();
return my_string.substring(0, s) + answer + my_string.substring(e + 1);
}
}
좀 더 간편하다랄까