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 */
vectorv;
int n,x;
cin>>n;
for(int i = 0; i>x;
v.push_back(x);
}
int y;
cin>>y;
v.erase(v.begin()+y-1);
int z,a;
cin>>z>>a;
v.erase(v.begin()+(z-1), v.begin()+(a-1));
cout<<v.size()<<endl;
for (int i = 0; i<v.size(); i++) {
cout<<v[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 →
Earasing the vectors using the C++ language
Code solution :
include
include
include
include
include
using namespace std;
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ vectorv; int n,x; cin>>n; for(int i = 0; i>x; v.push_back(x); } int y; cin>>y; v.erase(v.begin()+y-1); int z,a; cin>>z>>a; v.erase(v.begin()+(z-1), v.begin()+(a-1));
}