##
std::unique_copy in C++
July 25, 2017

std::unique is used to remove duplicates of any element present consecutively in a range[first, last). It performs this task for all the sub-groups present in… Read More »

July 25, 2017

std::unique is used to remove duplicates of any element present consecutively in a range[first, last). It performs this task for all the sub-groups present in… Read More »

std::swap is used for swapping of elements between two containers. One of its variation is std::swap_ranges, which as the name suggests is used for swapping… Read More »

If we have two iterators and we want to find the total no. of elements between the two iterators, then that is facilitated by std::distance(),… Read More »

upper_bound() is a standard library function in C++ defined in the header . It returns an iterator pointing to the first element in the range… Read More »

July 24, 2017

std::nth_element() is an STL algorithm which rearranges the list in such a way such that the element at the nth position is the one which… Read More »

For calculating the smallest of all the elements in a given list, we have std::min, but what if we want to find the smallest not… Read More »

For calculating the largest of all the elements in a given list, we have std::max, but what if we want to find the largest element… Read More »

std::max is defined in the header file <algorithm> and is used to find out the largest of the number passed to it. It returns the… Read More »

std::is_sorted_until is used to find out the first unsorted element in the range [first, last). It returns an iterator to the first unsorted element in… Read More »

Competitive programming often involves computation of Least Common Multiple (LCM) of two numbers. One way of doing that is using boost::math::lcm(), which we discussed in… Read More »

July 22, 2017

std::min is defined in the header file and is used to find out the smallest of the number passed to it. It returns the first… Read More »

Many times while we do programming, we need to calculate the Least Common Multiple (LCM) between two numbers. We have already discussed how to find… Read More »

std::equal() helps to compares the elements within the range [first_1,last_1) with those within range beginning at first_2. Syntax 1: template bool equal (InputIterator1 first1, InputIterator1… Read More »

std::advance advances the iterator ‘it’ by n element positions. Syntax : template void advance (InputIterator& it, Distance n); it : Iterator to be advanced n… Read More »