196. 문자열 여러 번 뒤집기

김해준's avatar
Jan 07, 2026
196. 문자열 여러 번 뒤집기

사용언어 : Java

문제
notion image
풀이
class Solution { public String solution(String my_string, int[][] queries) { String answer = my_string; for(int i = 0 ; i < queries.length; i++) { String temp = ""; int sIdx = queries[i][0]; int eIdx = queries[i][1]; for(int j = 0 ; j < answer.length(); j++) { if(j == sIdx) { for(int k = eIdx; k >= sIdx; k--) { temp += answer.charAt(k); j++; } } if(j >= answer.length())continue; temp += answer.charAt(j); } answer = temp; } return answer; } }
notion image
Share article