## Find k ordered pairs in array with minimum difference d

Given an array arr[] and two integers K and D, the task is to find exactly K pairs (arr[i], arr[j]) from the array such that… Read More »

## Find k closest numbers in an unsorted array

Given an unsorted array and two numbers x and k, find k closest values to x. Examples: Input : arr[] = {10, 2, 14, 4,… Read More »

## Keep track of previous indexes after sorting a vector in C++ STL

Prerequisite: vector, vector pair sorting Given a vector, keep track of the present indexes corresponding to each element and after sorting print element with its… Read More »

## Count triplet pairs (A, B, C) of points in 2-D space that satisfy the given condition

Given N points in 2 dimensional space. The task is to count the number of triplets pairs (A, B, C) such that point B is… Read More »

## How to create an unordered_map of pairs in C++?

Unordered Map does not contain a hash function for a pair like it has for int, string, etc, So if we want to hash a… Read More »

## Find the missing elements from 1 to M in given N ranges | Set-2

Given an integer and ranges (e.g. [a, b]) which are intersecting and overlapping. The task is to find all the number within the range that… Read More »

## Print all pairs in an unsorted array with equal sum

Given an unsorted array A[]. The task is to print all unique pairs in the unsorted array with equal sum. Note: Print the result in… Read More »

## Print Minimum of all Subarrays using set in C++ STL

Given an array of size N and an integer K, find the minimum for each and every contiguous subarray of size K. Examples: Input :… Read More »

## Sets of pairs in C++

Sets are a type of associative containers in which each element has to be unique, because the value of the element identifies it. The value… Read More »

## Perform the given queries on the rooted tree

Given a rooted tree and not necessarily binary. The tree contains N nodes, labeled 1 to N. You are given the tree in the form… Read More »

## Check if a king can move a valid move or not when N nights are there in a modified chessboard

Given an infinite chessboard with the same rules as that of chess. Also given are N knights coordinates on the infinite chessboard(-10^9 <= x, y… Read More »

## Minimum number of swaps required to sort an array | Set 2

Given an array of N distinct elements, find the minimum number of swaps required to sort the array. Note: The problem is not asking to… Read More »

## Count number of triplets with product equal to given number with duplicates allowed | Set-2

Given an array of positive integers(may contain duplicates) and a number ‘m’, find the number of unordered triplets ((Ai, Aj, Ak) and (Aj, Ai, Ak)… Read More »

## Longest subarray having average greater than or equal to x

Given an array of integers and an integer x. Find length of maximum size subarray having average of integers greater than or equal to x.… Read More »

## Priority queue of pairs in C++ (Ordered by first)

In C++, priority_queue implements heap. Below are some examples of creating priority queue of pair type. Max Priority queue (Or Max heap) ordered by first… Read More »