C++ STL Practice Problems
Standard Template Library (STL) is a C++ library that provides the built-in implementation of commonly used data structures and algorithms. These components are designed as templates for generic coding. It is must to have knowledge of STL not only for development but also for competitive programming.
Practicing problems is one of the most effective ways to improve programming fluency. This article provides you practice problems based on difficulty that will help you \master STL components such as algorithms, containers, functors, etc.
Easy Problems
The easy problems just include problems that requires the demonstration of basic operations of the STL components such as vector, set, etc.
- Vector Insertion
- Front to Back Traversal of Vector
- Back to Front Traversal of Vector
- Vector Sum
- Sort and Reverse Vector
- Vector Erase and Clear
- Find the Frequency of Elements
Medium Problems
This section includes the problems with some simple real-world applications of STL.
- Sort Vector of Pairs
- Vector Shrink to Fit
- Increasing Roll Numbers & Marks
- Maximum Among Left Elements
- Elements Less Than K
- Find Duplicate
Hard Problems
Hard section contains problems that uses STL with other concepts to provide a solution of the complex problems. It may include the use of some standard problem-solving algorithms and implementations of specialized data structures.
- Sorted Frequency Count
- Count Smaller Elements
- Most Occurring Elements
- Merge K Sorted Vectors
- Sort One Array According to Another
- Two Sum
Prerequisite
To solve the above problems, you should have the knowledge of the following concepts along with STL:
- C++ Fundamentals
- Functions
- Compound Data Types
- OOPs
- Templates
- STL
It may also require the understanding of some commonly used data structures. If you want to revise these concepts, refer to GeeksforGeeks' C++ Tutorial and DSA Tutorial.
How to solve practice problems?
Each of the above link will take you to the practice portal where the problem statement tells you all the required information about the problem, and you have to write the solution in the code editor.

Once your solution is complete, you can check it for example test case using the compile and run button at the bottom right of the page.

If you are sure of your solution, press the submit button. The GfG's compiler will run your solution for a variety of test cases and if all these cases are passed, you solution will be accepted.
Your own custom cases can also be checked before submission by using Custom Input button but keep in mind to follow the program's input layout.