문제
https://school.programmers.co.kr/learn/courses/30/lessons/12906
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
코드
#include <vector>
#include <iostream>
using namespace std;
vector<int> solution(vector<int> arr)
{
vector<int> answer;
answer.push_back(arr[0]);
int idx=0;
for(int i=1;i<arr.size();i++){
if(arr[i]==answer[idx])
continue;
else{
answer.push_back(arr[i]);
idx++;
}
}
return answer;
}
'PS > Programmers' 카테고리의 다른 글
[프로그래머스 Lv.2] 기능개발(C++) (0) | 2025.04.07 |
---|---|
[프로그래머스 Lv.2] 카펫(C++) (0) | 2025.04.03 |
[프로그래머스 Lv.1] 폰켓몬(C++) (0) | 2025.03.28 |
[프로그래머스 Lv.1] 완주하지 못한 선수(C++) (0) | 2025.03.24 |
[프로그래머스 Lv.2] 서버 증설 횟수(C++) (0) | 2025.03.22 |
댓글