문제 설명

솔루션
class Solution {
public String[] solution(String my_str, int n) {
int length = 0;
if(my_str.length() % n == 0){
length = my_str.length() / n;
}else{
length = my_str.length()/ n+1;
}
String[] answer = new String[length];
for(int i = 0; i < length; i++){
if(my_str.length() >= n){
answer[i] = my_str.substring(0, n);
my_str = my_str.substring(n, my_str.length()); //잘린 문자열 복구하기
}else{
answer[i] = my_str.substring(0, my_str.length());
}
}
return answer;
}
}'java' 카테고리의 다른 글
| [프로그래머스 - 자바] 문자열 계산하기 (0) | 2023.09.01 |
|---|---|
| [프로그래머스 - 자바] 영어가 싫어요 (0) | 2023.09.01 |
| [프로그래머스 - 자바] 공던지기 (0) | 2023.09.01 |
| [프로그래머스 - 자바] 소인수분해 (0) | 2023.09.01 |
| [프로그래머스 - 자바] 7의 개수 (0) | 2023.09.01 |