class Solution {
public String solution(int q, int r, String code) {
String answer = "";
return answer;
}
}
해결법
방법 1
class Solution {
public String solution(int q, int r, String code) {
String answer = "";
String[] str = code.split("");
for (int i = 0; i < str.length; i++) {
if (i % q == r) {
answer += str[i];
}
}
return answer;
}
}
방법 2
class Solution {
public String solution(int q, int r, String code) {
String answer = "";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < code.length(); i++) {
if (i % q == r) {
sb.append(code.charAt(i));
}
}
answer = sb.toString();
return answer;
}
}
qr code Lv. 0