반응형
https://www.hackerrank.com/challenges/vector-erase/problem
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n, x, temp, a, b;
vector<int> N;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> temp;
N.push_back(temp);
}
cin >> x >> a >> b;
vector<int>::iterator iter = N.begin();
iter -= 1;
N.erase(iter + x);
N.erase(iter + a, iter + b);
cout << N.size() << endl;
for (int i = 0; i < N.size(); i++) cout << N[i] << " ";
return 0;
}
반응형
'Training > HackerRank' 카테고리의 다른 글
[C++][STL] Lower Bound-STL (0) | 2021.08.08 |
---|---|
[C++][Introduction] Variable Sized Arrays (0) | 2021.08.07 |
[C++][Classes] Class (0) | 2021.08.07 |
[C++][Strings] StringStream (0) | 2021.08.04 |
[C++][Introduction] Pointer (0) | 2021.08.03 |