A vector is a type of container which can store objects of similar data type. Vector acts like a dynamic array where we can insert elements and the size of the array increases depending upon the elements inserted....
In C++, an array is a collection of elements of a single type while vectors are dynamic arrays as they can change their size during the insertion and deletion of elements. In this article, we will learn how to create a vector of arrays in C++....
In C++, a map is a container provided by the STL library that stores data in key-value pairs in an ordered or sorted manner. In this article, we will learn how to find the last key-value pair in a Map in C++....
In C++ STL (Standard Template Library), the set container represents a collection of unique, sorted elements. In this article, we will see how to an element in a set in C++ using iterators....
Round I
1.Implement expiry cache system : every page in cache have id and expiry time (TTL of few seconds). After page expires it behaves as free space and can be used for new pages/replacement. Had a long discussion on everything....
Given an undirected, connected and weighted graph, find Minimum Spanning Tree (MST) of the graph using Kruskal’s algorithm....
In C++, std::map is a container provided by the Standard Template Library (STL) that stores elements in key-value pairs, where the keys are sorted. In this article, we will learn how to find whether an element exists in std::map in C++....
forward_list::cbefore_begin() is an inbuilt function in CPP STL which returns a constant random access iterator which points to the position before the first element of the forward_list. The iterator obtained by this function can be used to iterate in the container but cannot be used to modify the content of the object to which it is pointing, even if the object itself is not constant....
In C++, vectors are dynamic arrays that can grow and reduce in size as per requirements. In this article, we will learn how to extract a subvector from a vector in C++....
When the container to which an Iterator points changes shape internally, i.e. when elements are moved from one position to another, and the initial iterator still points to the old invalid location, then it is called Iterator invalidation. One should be careful while using iterators in C++. When we iterate over our container using iterators then it may happen that the iterator gets invalidated. This may be due to change in the shape and size of the container while iterating....
Have you ever wondered why the rand() function always gives the same values each time we compile and run our code? well in this post we are going to discuss this phenomenon in brief....