diff --git a/Erasing_in_vector.cpp b/Erasing_in_vector.cpp new file mode 100644 index 0000000..83716ef --- /dev/null +++ b/Erasing_in_vector.cpp @@ -0,0 +1,36 @@ +/* + You are provided with a vector of integers. Then, you are given queries. + For the first query, you are provided with integer, which denotes a position in the vector. + The value at this position in the vector needs to be erased. The next query consists of integers denoting a range of the positions in the vector. + The elements which fall under that range should be removed. + The second query is performed on the updated vector which we get after performing the first query. +*/ +#include +#include +#include +#include +#include +using namespace std; + + +int main() { + /* Read input from STDIN. Print output to STDOUT */ + int n,x,a,b,temp; + vector v; + cin>>n; + for(int i=0;i>temp; + v.push_back(temp); + } + cin>>x; + cin>>a>>b; + v.erase(v.begin()+x-1); + v.erase(v.begin()+a-1,v.begin()+b-1); + cout< +#include +#include +#include +#include +using namespace std; + + +int main() { + /* Read input from STDIN. Print output to STDOUT */ + int n,x; + vector v; + cin>>n; + for(int i=0; i>x; + v.push_back(x); + } + sort(v.begin(),v.end()); + for(int i=0;i