From dc59ff82f95c3064b815e5e579123edcc69d2e24 Mon Sep 17 00:00:00 2001 From: Jatin Goel <44617146+JatinSH@users.noreply.github.com> Date: Thu, 3 Oct 2019 17:26:25 +0530 Subject: [PATCH 1/2] Vector Sort Sorting of n number of given integers using a vector --- sorting/Sort_vector.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 sorting/Sort_vector.cpp diff --git a/sorting/Sort_vector.cpp b/sorting/Sort_vector.cpp new file mode 100644 index 0000000..c317c36 --- /dev/null +++ b/sorting/Sort_vector.cpp @@ -0,0 +1,24 @@ +//sorting of n integers using vector +#include +#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 Date: Thu, 3 Oct 2019 17:33:10 +0530 Subject: [PATCH 2/2] Erasing elements in a vector --- Erasing_in_vector.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Erasing_in_vector.cpp 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<