## 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 »

## Print the DFS traversal step-wise (Backtracking also)

Given a graph, the task is to print the DFS traversal of a graph which includes the every step including the backtracking. 1st step:- 0… Read More »

## Sorting a vector in C++

Prerequisites : std::sort in C++, vector in C++, initialize a vector in C++. filter_none edit close play_arrow link brightness_4 code // C++ program to sort… Read More »

## How does a vector work in C++?

A Vectors in C++ can resize itself when more elements are added. It also allows deletion of elements. A basic idea is to double the… Read More »

## Check if a given graph is Bipartite using DFS

Given a connected graph, check if the graph is bipartite or not. A bipartite graph is possible if the graph coloring is possible using two… Read More »

## Maximum length of rod for Q-th person

Given lengths of n rods in an array a[]. If any person picks any rod, half of the longest rod (or (max + 1) /… Read More »

## Prime numbers in a given range using STL | Set 2

Generate all prime numbers between two given numbers. The task is to print prime numbers in that range. The Sieve of Eratosthenes is one of… Read More »

## Merge k sorted arrays | Set 2 (Different Sized Arrays)

Given k sorted arrays of possibly different sizes, merge them and print the sorted output. Examples: Input: k = 3 arr[][] = { {1, 3},… Read More »

## vector insert() function in C++ STL

std::vector::insert() is a built-in function in C++ STL which inserts new elements before the element at the specified position, effectively increasing the container size by… Read More »

## vector capacity() function in C++ STL

The vector::capacity() function is a built-in function which returns the size of the storage space currently allocated for the vector, expressed in terms of elements.… Read More »

## Program to print last N lines | Set-2

Given some text lines in one string, each line is separated by ‘\n’ character. Print the last N lines. If the number of lines is… Read More »

## vector rbegin() and rend() function in C++ STL

vector::rbegin() is a built-in function in C++ STL which returns a reverse iterator pointing to the last element in the container. Syntax: vector_name.rbegin() Parameters: The… Read More »

## Least Frequently Used (LFU) Cache Implementation

Least Frequently Used (LFU) is a caching algorithm in which the least frequently used cache block is removed whenever the cache is overflowed. In LFU… Read More »

## vector max_size() function in C++ STL

The vector::max_size() is a built-in function in C++ STL which returns the maximum number of elements that can be held by the vector container. Syntax:… Read More »

## vector shrink_to_fit() function in C++ STL

The vector::shrink_to_fit() is a built-in function in C++ STL which reduces the capacity of the container to fit its size and destroys all elements beyond… Read More »