Practice
Resources
Contests
Online IDE
New
Free Mock
Events New Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Events
Attend free live masterclass hosted by top tech professionals
New
Scaler
Explore Offerings by SCALER

# Vector

Vectors are same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted, with their storage being handled automatically by the container.
Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators.

• Declaration
`vector<int>v; (creates an empty vector of integers)vector<int>v(10); (creates an integer vector of size 10)vector<int>v(10, 0); (creates an integer vector of size 10, containing 0)`
• Size:
`int size = v.size();`
• Pushing an integer into a vector:
`v.push_back(x); (where x is an integer.The size increases by 1 after this.)`
• Popping the last element from the vector:
`v.pop_back(); (After this the size decreases by 1)`
• Sorting a vector:
`sort(v.begin(), v.end()); (Will sort all the elements in the vector)// begin() - Returns an iterator pointing to the first element in the vector// end() – Returns an iterator pointing to the theoretical element that follows the last element in the vector`
• erase(int position):
`Removes the element present at position.Ex: v.erase(v.begin()+4); (erases the fifth element of the vector v)`
• erase(int start,int end):
`Removes the elements in the range from start to end inclusive of the start and exclusive of the end.Ex: v.erase(v.begin()+2,v.begin()+5); (erases all the elements from the third element to the fifth element.)`

Try the following example in the editor below.

First line of the input contains an integer denoting the number of integers.
Second line contains N space-separated integers.
Third line contains an integer X denoting the index(0-based) of the N integers which needs to be deleted.

Your task is to print the N-1 integers in sorted order (ascending). Each integer in a new line.

Constraints

`1 <= N <= 105  0 <= X < N`

Sample Input

`510 5 2 3 102`

Sample Output

`351010`
Hints
• Complete Solution

## Discussion

Free Mock Assessment
Fill up the details for personalised experience.
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
*Enter the expected year of graduation if you're student
Current Employer
Company Name
College/University Name
Job Title
Job Title
Software Development Engineer (Backend)
Software Development Engineer (Frontend)
Software Development Engineer (Full Stack)
Data Scientist
Android Engineer
iOS Engineer
Devops Engineer
Support Engineer
Research Engineer
Engineering Intern
QA Engineer
Co-founder
SDET
Product Manager
Product Designer
Backend Architect
Program Manager
Release Engineer