웅재의 코딩세상
[프로그래머스] 배열의 원소만큼 추가하기 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> arr) {
vector<int> answer;
for(int i=0; i<arr.size(); i++){
for(int j=0; j<arr[i]; j++){
answer.push_back(arr[i]);
}
}
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] 할 일 목록 (0) | 2024.01.25 |
---|---|
[프로그래머스] 문자열 정수의 합 (0) | 2024.01.25 |
[프로그래머스] 뒤에서 5등까지 (1) | 2024.01.25 |
[프로그래머스] 순서 바꾸기 (0) | 2024.01.25 |
[프로그래머스] 문자열을 정수로 변환하기 (0) | 2024.01.25 |