※ 이번 문제에서 알게된 점
§ unique() 함수
https://chan4im.tistory.com/51
this.algorithm(2). 중복된 원소제거, unique()
chan4im.tistory.com
§ my solution
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int N; cin >> N;
vector<int> v;
for(int i = 0; i < N; i++){
int num; cin >> num;
v.push_back(num);
}
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
for(auto x:v)
cout << x << " ";
}
'Algorithms > Coding Test' 카테고리의 다른 글
[Baekjoon/백준] 11651번: [pair, sort_custom func] (C/C++) ★★★ (0) | 2022.11.03 |
---|---|
[Baekjoon/백준] 11004번, 2751번, 11931번(C/C++) / (알게된 내용X) (0) | 2022.11.03 |
[Baekjoon/백준] 11728번: 배열 합치기_merge(C/C++) / (알게된 점 多) (0) | 2022.11.03 |
[Baekjoon/백준] 2161번: 카드1_deque(C/C++) / (알게된 점X) (0) | 2022.11.02 |
[Baekjoon/백준] 2164번: 카드2_deque(C/C++) / (알게된 점X) (0) | 2022.11.02 |