공부기록/프로그래머스
[프로그래머스] 푸드 파이트 대회
메델
2024. 2. 4. 04:26
class Solution {
public String solution(int[] food) {
StringBuilder sb = new StringBuilder();
for(int i=1; i<food.length; i++){
int num = food[i]/2;
for(int j=0; j<num; j++){
sb.append(i);
}
}
StringBuilder reverseSb = new StringBuilder(sb).reverse();
sb.append(0).append(reverseSb);
return sb.toString();
}
}