public String solution(int[] food) {
StringBuilder answer = new StringBuilder();
StringBuilder left = new StringBuilder();
StringBuilder right = new StringBuilder();
for (int i = 1; i < food.length; i++) {
if (food[i] != 0) {
int halfCount = food[i] / 2;
left.append(String.valueOf(i).repeat(halfCount));
right.insert(0, String.valueOf(i).repeat(halfCount));
}
}
answer.append(left).append("0").append(right);
return answer.toString();
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/134240
잘 읽었습니다. 좋은 정보 감사드립니다.