SlideShare a Scribd company logo
1 of 15
C++ STL with Problem Solving
Google Developer Students Club
Indian Institute of InformationTechnology, Kota
Introduction to STL
• The StandardTemplate Library (STL) is a set of C++ template
classes to provide common programming data structures and
functions such as lists, stacks, arrays, etc.
• It is a library consisting of 4 components:
1.Algorithms
2.Containers
3.Functions
4.Iterators
Vector
Vectors are the 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.
Syntax : vector < datatype > name initial size ;
Methods :
• push_back(val), insert(index, val), pop_back(), erase(position)
• begin(), end(), rbegin(), rend()
• size(), empty()
Pairs
Pair is used to combine together two values that may be different in
type.The first element is referenced as ‘first’ and the second
element as ‘second’ and the order is fixed (first, second).
Syntax : pair < datatype, datatype > name;
Methods :
• make_pair(value_1, value_2)
• first, second - (accessing elements)
• swap(another_pair)
Iterators
Iterators are used to point at the memory addresses of STL
containers.They are primarily used in sequences of numbers,
characters etc.
Syntax : container<datatype>::iterator name;
Methods :
• begin(), end(), rbegin(), rend()
• advance(itr, steps)
• next(itr, steps), prev(itr, steps) – returns iterator
Stack
Stacks are a type of container adaptors with LIFO(Last In First Out)
type of working, where a new element is added at one end (top) and
an element is removed from that end only.
Syntax : stack < datatype > name;
Methods :
• push(val), pop()
• top() - (accessing elements)
• size(), empty()
Queue
Queues are a type of container adaptors that operate in a first in
first out (FIFO) type of arrangement. Elements are inserted at the
back (end) and are deleted from the front.
Syntax : queue < datatype > name;
Methods :
• push(val), pop()
• front(), back() - (accessing elements)
• size(), empty()
Priority Queue / Heap
Priority queues are designed such that the first element of the queue is either the
greatest or the smallest of all elements in the queue.
Syntax :
priority_queue < datatype > name; (max heap)
priority_queue < datatype, vector < datatype >, greater < datatype >> name;
(min heap)
Methods :
• push(val), pop()
• top() - (accessing elements)
• size(), empty()
Set / Unordered Set
Sets are a type of associative container in which each element has to be unique
because the value of the element identifies it.The values are stored in a specific
sorted order.
Syntax : set < datatype > name;
Methods :
• insert(), erase()
• begin(), end(), rbegin(), rend()
• size(), empty()
Map / Unordered Map
Maps are associative containers that store elements in a mapped fashion. Each
element has a key value and a mapped value. No two mapped values can have the
same key values.
Syntax : map < datatype, datatype > name;
Methods :
• insert(pair<int,int>(key,val))
• erase() – (value/iterator)
• begin(), end(), rbegin(), rend()
• size(), empty()
Algorithm Library
STL has a large number of inbuilt functions which are available in the algorithm
library.
Some important and frequently used functions are :
• sort(first_iterator, last_iterator);
• reverse(first_iterator, last_iterator);
• *max_element(first_iterator, last_iterator);
• *min_element(first_iterator, last_iterator);
• accumulate(first_iterator, last_iterator, initial_sum);
• count(first_iterator, last_iterator, element);
• find(first_iterator, last_iterator, element);
Algorithm Library
Additional functions:
• fill_n(start_iterator, range, value);
• lower_bound(start_iterator, end_iterator, value);
• upper_bound(start_iterator, end_iterator, value);
• is_sorted(start_iterator, end_iterator);
For the list of all STL algorithm library functions, visit the link below.
https://cplusplus.com/reference/algorithm/
Problem Solving
You will always learn more by solving questions.
Practice problems
1. https://codeforces.com/problemset/problem/22/A
2. https://codeforces.com/contest/855/problem/A
3. https://codeforces.com/contest/1277/problem/B
4. https://codeforces.com/contest/1728/problem/C
Thank You!
Google Developer Students Club
Indian Institute of InformationTechnology, Kota

More Related Content

What's hot

Quick sort algorithn
Quick sort algorithnQuick sort algorithn
Quick sort algorithnKumar
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Deepak John
 
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIAlgorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIMohamed Loey
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programmingShakil Ahmed
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 
Sorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderSorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderAshin Guha Majumder
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2Kumar
 
module4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfmodule4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfShiwani Gupta
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)Elavarasi K
 

What's hot (20)

Quick sort algorithn
Quick sort algorithnQuick sort algorithn
Quick sort algorithn
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
3.8 quicksort
3.8 quicksort3.8 quicksort
3.8 quicksort
 
Branch & bound
Branch & boundBranch & bound
Branch & bound
 
STL in C++
STL in C++STL in C++
STL in C++
 
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIAlgorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms II
 
Counting sort
Counting sortCounting sort
Counting sort
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Recurrences
RecurrencesRecurrences
Recurrences
 
Mergesort
MergesortMergesort
Mergesort
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
Complexity analysis in Algorithms
Complexity analysis in AlgorithmsComplexity analysis in Algorithms
Complexity analysis in Algorithms
 
Sorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderSorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha Majumder
 
14 Skip Lists
14 Skip Lists14 Skip Lists
14 Skip Lists
 
Shell sort[1]
Shell sort[1]Shell sort[1]
Shell sort[1]
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 
module4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdfmodule4_dynamic programming_2022.pdf
module4_dynamic programming_2022.pdf
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Daa unit 4
Daa unit 4Daa unit 4
Daa unit 4
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)
 

Similar to C++ STL

Stl (standard template library)
Stl (standard template library)Stl (standard template library)
Stl (standard template library)Hemant Jain
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++•sreejith •sree
 
python-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptxpython-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptxAkashgupta517936
 
Standard template library
Standard template libraryStandard template library
Standard template librarySukriti Singh
 
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...HendraPurnama31
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesAndrew Ferlitsch
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template LibraryGauravPatil318
 
Introduction to array and string
Introduction to array and stringIntroduction to array and string
Introduction to array and stringMuntasirMuhit
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1blessyboban92
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...nsitlokeshjain
 

Similar to C++ STL (20)

Stl (standard template library)
Stl (standard template library)Stl (standard template library)
Stl (standard template library)
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 
python-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptxpython-numpyandpandas-170922144956 (1).pptx
python-numpyandpandas-170922144956 (1).pptx
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
 
Numpy.pdf
Numpy.pdfNumpy.pdf
Numpy.pdf
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
 
C++ STL 概觀
C++ STL 概觀C++ STL 概觀
C++ STL 概觀
 
R training3
R training3R training3
R training3
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
 
R training2
R training2R training2
R training2
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
Introduction to array and string
Introduction to array and stringIntroduction to array and string
Introduction to array and string
 
C_STL_2.pptx
C_STL_2.pptxC_STL_2.pptx
C_STL_2.pptx
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
Data structures
Data structures Data structures
Data structures
 
9 python data structure-2
9 python data structure-29 python data structure-2
9 python data structure-2
 
Queues
Queues Queues
Queues
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
 

Recently uploaded

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

C++ STL

  • 1. C++ STL with Problem Solving Google Developer Students Club Indian Institute of InformationTechnology, Kota
  • 2. Introduction to STL • The StandardTemplate Library (STL) is a set of C++ template classes to provide common programming data structures and functions such as lists, stacks, arrays, etc. • It is a library consisting of 4 components: 1.Algorithms 2.Containers 3.Functions 4.Iterators
  • 3. Vector Vectors are the 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. Syntax : vector < datatype > name initial size ; Methods : • push_back(val), insert(index, val), pop_back(), erase(position) • begin(), end(), rbegin(), rend() • size(), empty()
  • 4. Pairs Pair is used to combine together two values that may be different in type.The first element is referenced as ‘first’ and the second element as ‘second’ and the order is fixed (first, second). Syntax : pair < datatype, datatype > name; Methods : • make_pair(value_1, value_2) • first, second - (accessing elements) • swap(another_pair)
  • 5. Iterators Iterators are used to point at the memory addresses of STL containers.They are primarily used in sequences of numbers, characters etc. Syntax : container<datatype>::iterator name; Methods : • begin(), end(), rbegin(), rend() • advance(itr, steps) • next(itr, steps), prev(itr, steps) – returns iterator
  • 6. Stack Stacks are a type of container adaptors with LIFO(Last In First Out) type of working, where a new element is added at one end (top) and an element is removed from that end only. Syntax : stack < datatype > name; Methods : • push(val), pop() • top() - (accessing elements) • size(), empty()
  • 7. Queue Queues are a type of container adaptors that operate in a first in first out (FIFO) type of arrangement. Elements are inserted at the back (end) and are deleted from the front. Syntax : queue < datatype > name; Methods : • push(val), pop() • front(), back() - (accessing elements) • size(), empty()
  • 8. Priority Queue / Heap Priority queues are designed such that the first element of the queue is either the greatest or the smallest of all elements in the queue. Syntax : priority_queue < datatype > name; (max heap) priority_queue < datatype, vector < datatype >, greater < datatype >> name; (min heap) Methods : • push(val), pop() • top() - (accessing elements) • size(), empty()
  • 9. Set / Unordered Set Sets are a type of associative container in which each element has to be unique because the value of the element identifies it.The values are stored in a specific sorted order. Syntax : set < datatype > name; Methods : • insert(), erase() • begin(), end(), rbegin(), rend() • size(), empty()
  • 10. Map / Unordered Map Maps are associative containers that store elements in a mapped fashion. Each element has a key value and a mapped value. No two mapped values can have the same key values. Syntax : map < datatype, datatype > name; Methods : • insert(pair<int,int>(key,val)) • erase() – (value/iterator) • begin(), end(), rbegin(), rend() • size(), empty()
  • 11. Algorithm Library STL has a large number of inbuilt functions which are available in the algorithm library. Some important and frequently used functions are : • sort(first_iterator, last_iterator); • reverse(first_iterator, last_iterator); • *max_element(first_iterator, last_iterator); • *min_element(first_iterator, last_iterator); • accumulate(first_iterator, last_iterator, initial_sum); • count(first_iterator, last_iterator, element); • find(first_iterator, last_iterator, element);
  • 12. Algorithm Library Additional functions: • fill_n(start_iterator, range, value); • lower_bound(start_iterator, end_iterator, value); • upper_bound(start_iterator, end_iterator, value); • is_sorted(start_iterator, end_iterator); For the list of all STL algorithm library functions, visit the link below. https://cplusplus.com/reference/algorithm/
  • 13. Problem Solving You will always learn more by solving questions.
  • 14. Practice problems 1. https://codeforces.com/problemset/problem/22/A 2. https://codeforces.com/contest/855/problem/A 3. https://codeforces.com/contest/1277/problem/B 4. https://codeforces.com/contest/1728/problem/C
  • 15. Thank You! Google Developer Students Club Indian Institute of InformationTechnology, Kota