◈ 문제 설명
◈ 문제 설명 링크
코딩테스트 연습 - 제일 작은 수 제거하기 | 프로그래머스 스쿨
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
◈ 작성 코드
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> arr)
{
vector<int> answer;
vector<int> ace = arr;
sort(arr.begin(), arr.end());
if(arr.size() > 1)
{
for(int i = 0; i < ace.size(); i++)
{
for(int j = 1; j < arr.size(); j++)
{
if(ace[i] == arr[j])
{
answer.push_back(ace[i]);
}
}
}
}
else
{
answer.push_back(-1);
}
return answer;
}
'[프로그래머스 C++] > LEVEL 1' 카테고리의 다른 글
[프로그래머스 C++] 정수 내림차순으로 배치하기 (0) | 2025.04.02 |
---|---|
[프로그래머스 C++] 정수 제곱근 판별 (0) | 2025.04.02 |
[프로그래머스 C++] 짝수와 홀수 (0) | 2025.04.01 |
[프로그래머스 C++] 최대공약수와 최소공배수 (0) | 2025.04.01 |
[프로그래머스 C++] 콜라츠 추측 (0) | 2025.04.01 |