## Implementing Counting Sort using map in C++

Counting Sort is one of the best sorting algorithms which can sort in O(n) time complexity but the disadvantage with the counting sort is it’s… Read More »

## How to swap Keys with Values of a Map in C++?

Given a map, the task is to swap the Keys of this map with its values, in C++. Examples: Input: map = {‘e’, 1 },… Read More »

## Find the number of p-sided squares in a grid with K blacks painted

Given a grid of size H*W with all cells initially white. Given N pairs (i, j) in an array, for each pair, paint cell (i,… Read More »

## Minimum Bitwise XOR operations to make any two array elements equal

Given an array arr[] of integers of size N and an integer K. One can perform the Bitwise XOR operation between any array element and… Read More »

## Print elements of an array according to the order defined by another array | set 2

Given two arrays a1[] and a2[], print elements of a1 in such a way that the relative order among the elements will be the same… Read More »

## Find whether an array is subset of another array using Map

Given two arrays: arr1[0..m-1] and arr2[0..n-1]. Find whether arr2[] is a subset of arr1[] or not. Both the arrays are not in sorted order. It… Read More »

## Find sub-arrays from given two arrays such that they have equal sum

Given two arrays A[] and B[] of equal sizes i.e. N containing integers from 1 to N. The task is to find sub-arrays from the… Read More »

## Count of quadruplets with given Sum | Set 2

Given four arrays containing integer elements and an integer sum, the task is to count the quadruplets such that each element is chosen from a… Read More »

## Find number of unique triangles among given N triangles

Given three arrays a[], b[] and c[] of N elements representing the three sides of N triangles. The task is to find the number of… Read More »

## Check if frequency of characters are in Recaman Series

Given a string of lowercase alphabets. The task is to check whether the frequency of alphabets in this string, after arranging in any possible manner,… Read More »

## Choose atleast two elements from array such that their GCD is 1 and cost is minimum

Given two integer arrays arr[] and cost[] where cost[i] is the cost of choosing arr[i]. The task is to choose a subset with at least… Read More »

## map get_allocator in C++ STL

map::get_allocator() is a built in function in C++ STL which is used to get allocator of container map. Syntax: Allocator_type get_allocator() Parameters: This function does… Read More »

## Find the Number of Maximum Product Quadruples

Given an array of N positive elements find the number of quadruple, (i, j, k, m) such that i < j < k < m… Read More »

## How to delete last element from a map in C++

If we wish to delete the last element from a map, we can use following methods : using prev(mp.end()) : what prev function do is,… Read More »

## How to traverse a STL map in reverse direction?

Map stores the elements in sorted order of keys. Now if we want to traverse it in reverse order we will use reverse_iterator of map.… Read More »