Skip to content

Tag Archives: cpp-iterator

Given a Binary Tree and an input array. The task is to create an Iterator that utilizes next() and hasNext() functions to perform Inorder traversal… Read More
Given a string str of length N, the task is to traverse the string and print all the characters of the given string. Examples: Input:… Read More
Prerequisite: Iterators in STL Iterators are objects similar to pointers which are used to iterate over a sequence and manipulate the container elements. The advantage… Read More
Range-Based ‘for’ loops have been included in the language since C++11. It automatically iterates (loops) over the iterable (container). This is very efficient when used… Read More
Prerequisite: C++ STL, Iterators in C++ STL The iterator is not the only way to iterate through any STL container. There exists a better and… Read More
Given a Vector of Vectors (2D vector), the task is to flatten this 2d vector. Examples: Input: vector = [[1, 2, 3, 4], [5, 6],… Read More
Prerequisite: Arrays in C++, Vector in C++ STL An array is a collection of items stored at contiguous memory locations. It is to store multiple… Read More
Given K vectors, the task is to design a cyclic iterator that prints the elements of these vectors in a cyclic manner. For example: v1… Read More
Pointer: A pointer is a variable which contains the address of another variable, i.e., address of the memory location of the variable. Like any variable… Read More
Given a List, the task is to delete a range of values from this List using Iterator. Example: Input: list = [10 20 30 40… Read More
Given a Set, the task is to delete a range of values from this Set using Iterator. Example: Input: set = [10 20 30 40… Read More
regex_iterator() is a function from the BiDirectionalIterator class in C++. This method returns an iterator type to iterate over different matches of a same regex… Read More
The rend() function is an inbuilt function in C++ STL which returns a reverse iterator pointing to the theoretical element right before the first key-value… Read More
forward_list::cend() is a function in C++ STL which returns a constant iterator pointing to the past-the-last element of the forward_list. The iterator returned by the… Read More
Given a program that uses an iterator, the task is to find the type of iterator used. Examples: Input : vector.begin() Output : Random_Access Iterator… Read More