Smallest Greater (than S) String of length K whose letters are subset of S

Given a string S of length N consisting of lowercase English letters and an integer K. Find the lexicographically smallest string T of length K,… Read More »

How to delete last element from a set in C++

Given a Set, the task is to remove the last element from this Set in C++. Examples: Input: set = [10 20 30 70 80… Read More »

How to traverse a C++ set in reverse direction

Given a Set, the task is to traverse this Set in reverse order. Examples: Input: set = [10 20 30 70 80 90 100 40… Read More »

Closest greater or same value on left side for every element in array

Given an array of integers, find the closest (not considering distance, but value) greater or same value on left of every element. If an element… Read More »

Count pairs from two arrays whose modulo operation yields K

Given an integer and two arrays and , the task is to count the total pairs (formed after choosing an element from and another from… Read More »

Minimum array elements to be changed to make it a Lucas Sequence

Given an array with N distinct elements. The task is to find the minimum number of elements to be changed in the array such that,… Read More »

Maximum value of XOR among all triplets of an array

Given an array of integers ‘arr’, the task is to find the maximum XOR value of any triplet pair among all the possible triplet pairs.… 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 »

Longest subarray with only one value greater than k

Given an array of N numbers, find length of the longest subarray such that K is the second largest element on insertion. Examples: Input: a[]… 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 »

set get_allocator() in C++ STL

The set::get_allocator() in C++ STL is an in-built function which returns the copy of the allocator object associated with the set. Syntax: mulset.get_allocator(); Parameters: This… Read More »

set operator= in C++ STL

The ‘=’ is an operator in C++ STL which copies (or moves) a set to another set and set::operator= is the corresponding operator function. There… Read More »

Queries to add, remove and return the difference of maximum and minimum.

Given Q queries. The queries are of three types and are described below: Add the number num to the list. Remove the number num from… Read More »

Queries on insertion of an element in a Bitonic Sequence

Given a Bitonic sequence ‘S’ and ‘Q’ no. of queries. Each query contain an integer xi, 1 <= i <= Q. The task is 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 »