내 답안
class Solution {
public String solution(int q, int r, String code) {
StringBuilder answer = new StringBuilder();
for (int i = r; i < code.length(); i += q) {
answer.append(code.charAt(i));
}
return answer.toString();
}
}
Java
복사
다른사람 풀이
class Solution {
public String solution(int q, int r, String code) {
String answer = "";
for(int i = 0; i < code.length(); i ++){
if(i % q == r){
answer += code.charAt(i);
}
}
return answer;
}
}
Java
복사
class Solution {
public String solution(String my_string, int s, int e) {
char[] arr = my_string.toCharArray();
while (s < e) {
char temp = arr[s];
arr[s++] = arr[e];
arr[e--] = temp;
}
return new String(arr);
}
}
Java
복사