์ฒด๊ฐ Level : โ
โโ Review: ์ ์๋ฐฐ์ด์ ๋ฌธ์์ด๋ฐฐ์ด๋ก ๋ฐ๊พธ๊ธฐ |
๐ก ์ ์ ๋ฐฐ์ด ์์ 7์ด ๋ช๊ฐ ์๋์ง ๋ฐํ
import java.util.ArrayList;
class Solution {
public ArrayList<String> solution(String my_str, int n) {
ArrayList<String> answer = new ArrayList<String>();
if (my_str.length() % n == 0){
for (int i = 0; i < my_str.length(); i+=n){
answer.add(my_str.substring(i,i+n));
}
}else {
int tmp = my_str.length()/n * n;
int tmp2 = my_str.length()%n;
for (int i = 0; i < tmp; i+=n){
answer.add(my_str.substring(i,i+n));
}
answer.add(my_str.substring(tmp));
}
return answer;
}
}