쉬운 문제다.
최소 index를 지워서 erase 해주면 됨. 빈 배열이라면 -1을 집어넣는다.
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> arr) {
arr.erase(min_element(arr.begin(), arr.end()));
if (arr.size() == 0)
arr.push_back(-1);
return arr;
}'Coding_Test 연습 > Programmers' 카테고리의 다른 글
| [프로그래머스] (C++) LV1 최대공약수와 최소공배수 (0) | 2022.04.27 |
|---|---|
| [프로그래머스] (C++) LV1 짝수와 홀수 (0) | 2022.04.27 |
| [프로그래머스] (C++) LV1 정수 제곱근 판별 (0) | 2022.04.27 |
| [프로그래머스] (C++) LV1 정수 내림차순으로 배치하기 (0) | 2022.04.27 |
| [프로그래머스] (C++) LV1 자연수 뒤집어 배열로 만들기 (0) | 2022.04.27 |