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.
#include<vector>#include<iostream>#include<algorithm>#include<iterator>usingnamespacestd;intmain(){vector<int>v;intx,a,b;//x=elem to remove, a and b=range to removeintsize;//size of vectorcin>>size;//fill vectorcopy_n(istream_iterator<int>(cin),size,back_inserter(v));cin>>x;//insert element to removev.erase(v.begin()+(--x));cin>>a>>b;//insert range to removev.erase(v.begin()+(--a),v.begin()+(--b));cout<<v.size()<<endl;//output size of vector//output vectcopy(v.begin(),v.end(),ostream_iterator<int>(cout," "));return0;}
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 →