# Tag Archives: cpp-set

## Longest subarray with difference exactly K between any two distinct values

Given an array arr[] of length N and an integer K, the task is to find the longest subarray with difference between any two distict… Read More »

## Largest subset with M as smallest missing number

Given an array arr[] of N positive integers and a positive integer M, the task is to find the length of longest subset whose smallest… Read More »

## Maximize count of distinct elements possible in an Array from the given operation

Given an array A[] of size N, the task is to maximize the count of distinct elements in the array by inserting the absolute differences… Read More »

## Smallest number to be added in first Array modulo M to make frequencies of both Arrays equal

Given two arrays A[] and B[] consisting of N positive integers and a integer M, the task is to find the minimum value of X… Read More »

## Count of prime factors of N to be added at each step to convert N to M

Given two integers N and M, the task is to find out minimum number of operations required to convert N to M. Each operation involves… Read More »

## Most frequent element in Array after replacing given index by K for Q queries

Given an array arr[] of size N, and Q queries of the form {i, k} for which, the task is to print the most frequent… Read More »

## Minimize K whose XOR with given array elements leaves array unchanged

Given an array of N elements, the task is to find the minimum value of K such that Bitwise XOR of K with all array… Read More »

## Min number of moves to traverse entire Matrix through connected cells with equal values

Given a matrix A[][] of dimensions N*M, the task is to find the minimum number of moves required to traverse the entire matrix starting from… Read More »

## Print the element at a given index in a Set in C++

Given a Set of integers sett and an integer index, the task is to find the element in the set which is present at index.… Read More »

## Check if K distinct array elements form an odd sum

Given an array A[] of size N, the task is to check if it is possible to get odd sum using K distinct elements from… Read More »

## Implementation of lower_bound and upper_bound on Set of Pairs in C++

Prerequisite: set lower_bound() function in C++ STL, set upper_bound() function in C++ STL lower_bound() returns an iterator pointing to the first element in the range… Read More »

## How to convert a Vector to Set in C++

This article shows how to convert a vector to a set in C++. Example: Input: vector = {1, 2, 3, 1, 1} Output: set =… Read More »

## Implementing upper_bound() and lower_bound() for Ordered Set in C++

Prerequisites: Ordered Set and GNU C++ PBDS Given an ordered set set and a key K, the task is to find the upper bound and… Read More »

## Set of Vectors in C++ STL with Examples

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

## Find the smallest positive number missing from an unsorted array | Set 3

Given an unsorted array with both positive and negative elements. The task is to find the smallest positive number missing from the array. Examples: Input:… Read More »