We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
vector v;
int n, loc, start, end;
cin >> n;
for (int i=0; i < n ; i++) {
int element;
cin >> element;
v.push_back(element);
}
cin >> loc;
v.erase(v.begin()+loc-1);
cin >> start >> end;
v.erase(v.begin()+start-1,v.begin()+end-1);
cout << v.size() << endl;
for ( int i : v){
cout << i << " ";
}
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Vector-Erase
You are viewing a single comment's thread. Return to all comments →
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ vector v; int n, loc, start, end; cin >> n; for (int i=0; i < n ; i++) { int element; cin >> element; v.push_back(element); }
}