728x90
https://school.programmers.co.kr/learn/courses/30/lessons/181861
📝 나의 풀이
using System;
public class Solution {
public int[] solution(int[] arr) {
int index = 0;
for(int i=0; i<arr.Length; i++){
index +=arr[i];
}
int[] answer = new int[index];
int answerIndex = 0;
for(int i=0; i<arr.Length; i++){
for(int j=0; j<arr[i]; j++){
answer[answerIndex] = arr[i];
answerIndex++;
}
}
return answer;
}
}
728x90
'코딩테스트 > [C#] 프로그래머스' 카테고리의 다른 글
[프로그래머스 | C# | Lv.0] 순서 바꾸기 (0) | 2023.09.05 |
---|---|
[프로그래머스 | C# | Lv.0] 0 떼기 (0) | 2023.09.05 |
[프로그래머스 | C# | Lv.0] 더 크게 합치기 (0) | 2023.09.04 |
[프로그래머스 | C# | Lv.0] 홀짝 구분하기 (0) | 2023.09.04 |
[프로그래머스 | C# | Lv.0] 홀짝에 따라 다른 값 반환하기 (0) | 2023.09.04 |