๋ฌธ์ ๋งํฌ : https://school.programmers.co.kr/learn/courses/30/lessons/134240
class Solution {
public String solution(int[] food) {
String answer = "";
for(int i=1;i<food.length;i++){
for(int j=0;j<food[i]/2;j++){
answer += String.valueOf(i);
}
}
String temp = new String(answer);
answer += "0";
for(int k=temp.length()-1;k>-1;k--){
answer += String.valueOf(temp.charAt(k));
}
return answer;
}
}
class Solution {
public String solution(int[] food) {
String answer = "0";
for (int i = food.length - 1; i > 0; i--) {
for (int j = 0; j < food[i] / 2; j++) {
answer = i + answer + i;
}
}
return answer;
}
}
'๐ป Coding Problems Solving > Hack' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JAVA] ์ ๊ท์์ด๋ ์ถ์ฒ์ผ๋ก ์์๋ณด๋ regex (0) | 2022.10.14 |
---|---|
[JAVA] ๋คํธ๊ฒ์์ ํตํด ์์๋ณด๋ char ๋ฌธ์/์ซ์ ํ์ธ (0) | 2022.10.14 |
[JAVA] 2์ง์, 8์ง์, 16์ง์ + ์ฑ์๋ฃ๊ธฐ! (0) | 2022.10.13 |
[JAVA] ์์ ์ํธ (0) | 2022.10.13 |
[JAVA] ์ฝ๋ฉํ ์คํธ ์ ์ฉํ ์ฝ๋ ๋ชจ์ (0) | 2022.10.07 |
์ต๊ทผ๋๊ธ