๋ฌธ์ ๋ฅผ ์๋ชป์ดํดํด์ for ๋ฌธ์ผ๋ก ์งํํด๋ณด๋ ค๋ค๊ฐ ๋งํ๋๋ฐ
์ธ๋ฑ์ค s ~ ์ธ๋ฑ์ค e๊น์ง ์ ๋ถ ๋ฐ๊พธ๋๊ฑฐ๋ค.
while ๋ฌธ์ผ๋ก ํ๋ฉด ์ฝ๊ฒ ๊ฐ๋ฅํ๋ค.
๋ฐ๊ฟ์ฃผ๊ณ a++ b-- ํ๋ฉฐ 1 5 / 2 4 ์ด๋ฐ์์ผ๋ก ๋ฐ๊ฟ์ค๋ค.
a๊ฐ b ๋ณด๋ค ์์๋๊น์ง๋ง! ์งํํด์ฃผ๋ฉด ๋จ!
class Solution {
public String solution(String my_string, int[][] queries) {
char[] num = my_string.toCharArray();
String answer = "" ;
char tmp ;
for (int i = 0; i < queries.length; i++){
int a = queries[i][0];
int b = queries[i][1];
while (a < b) {
char temp = num[a];
num[a] = num[b];
num[b] = temp;
a++;
b--;
}
}
answer = String.valueOf(num);
return answer;
}
}