Skip to content

Tag Archives: cpp-vector

Given a graph, the task is to print the DFS traversal of a graph which includes every step including the backtracking. 1st step:- 0 ->… Read More
Prerequisites : std::sort in C++, vector in C++, initialize a vector in C++.  CPP // C++ program to sort a vector in non-decreasing // order.… Read More
A Vectors in C++ can resize itself when more elements are added. It also allows deletion of elements. Below is a very basic idea when array… Read More
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
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
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
Given k sorted arrays of possibly different sizes, merge them and print the sorted output.Examples:  Input: k = 3 arr[][] = { {1, 3}, {2,… Read More
std::vector::insert() is a built-in function in C++ STL that inserts new elements before the element at the specified position, effectively increasing the container size by… Read More
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
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() 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 function… Read More
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
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
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
The std::vector::data() is an STL in C++ which returns a direct pointer to the memory array used internally by the vector to store its owned… Read More