웅재의 코딩세상
[프로그래머스] 제일 작은 수 제거하기 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> arr) {
vector<int> answer;
int min=1000000;
int num=0;
for(int i=0; i<arr.size(); i++){
if(arr[i]<min){
min = arr[i];
num = i;
}
}
arr.erase(arr.begin() + num);
answer = arr;
if (answer.size()==0) answer.push_back(-1);
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 1' 카테고리의 다른 글
[프로그래머스] 정수 내림차순으로 배치하기 (0) | 2024.02.09 |
---|---|
[프로그래머스] 정수 제곱근 판별 (0) | 2024.02.09 |
[프로그래머스] 짝수와 홀수 (0) | 2024.02.09 |
[프로그래머스] 최대공약수와 최소공배수 (0) | 2024.02.09 |
[프로그래머스] 콜라츠 추측 (0) | 2024.02.09 |