# Tag Archives: STL

## Sorting 2D Vector in C++ | Set 2 (In descending order by row and column)

We have discussed some of the cases of sorting 2D vector in below set 1. Sorting 2D Vector in C++ | Set 1 (By row… Read More »

## Sorting 2D Vector in C++ | Set 1 (By row and column)

What is a 2D Vector? A 2D vector is vector of vectors. It is an matrix implemented with the help of vectors. filter_none edit close… Read More »

## Find subarray with given sum | Set 2 (Handles Negative Numbers)

Given an unsorted array of integers, find a subarray which adds to a given number. If there are more than one subarrays with the sum… Read More »

## Sorting Vector of Pairs in C++ | Set 2 (Sort in descending order by first and second)

We have discussed some of the cases of sorting vector of pairs in below set 1. Sorting Vector of Pairs in C++ | Set 1… Read More »

## Sorting Vector of Pairs in C++ | Set 1 (Sort by first and second)

What is Vector of Pairs? A pair is a container which stores two values mapped to each other, and a vector containing multiple number of… Read More »

## std::tuple, std::pair | Returning multiple values from a function using Tuple and Pair in C++

There can be some instances where you need to return multiple values (may be of different data types ) while solving a problem. One method… Read More »

## Algorithm Library | C++ Magicians STL Algorithm

For all those who aspire to excel in competitive programming, only having a knowledge about containers of STL is of less use till one is… Read More »

## Common Subtleties in  Vector STLs

Prerequisite – Vector Basics Following are some important points that can save time on little things in an interview or an important coding contest. vector… Read More »

## Design a stack that supports getMin() in O(1) time and O(1) extra space

Question: Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return… Read More »

## Permutations of a given string using STL

A permutation, also called an “arrangement number” or “order”, is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with… Read More »

## Check if two trees are Mirror

Given two Binary Trees, write a function that returns true if two trees are mirror of each other, else false. For example, the function should… Read More »

## Count number of unique Triangles using STL | Set 1 (Using set)

We are given n triangles along with length of their three sides as a,b,c. Now we need to count number of unique triangles out of… Read More »

## Kruskal’s Minimum Spanning Tree using STL in C++

Given an undirected, connected and weighted graph, find Minimum Spanning Tree (MST) of the graph using Kruskal’s algorithm. Input : Graph as an array of… Read More »

## Functors in C++

Please note that the title is Functors (Not Functions)!! Consider a function that takes only one argument. However, while calling this function we have a… Read More »

## std::transform() in C++ STL (Perform an operation on all elements)

Consider the problem of adding contents of two arrays into a third array. It is given that all arrays are of same size. Following is… Read More »