Get Map Element at Offset in C++ STL
Prerequisites: Map in C++ STL...
read more
unordered_map bucket() in C++ STL
The unordered_map::bucket() is a built-in STL function in C++ which returns the bucket number where the element with the key k is located in the map. Syntax:...
read more
priority_queue::swap() in C++ STL
Priority queues are a type of container adaptors, specifically designed such that the first element of the queue is either the greatest or the smallest of all elements in the queue. However, in C++ STL (by default) the largest element is at the top. We can also create a priority queue having the smallest element at the top by simply passing an extra parameter while creating the priority queue....
read more
list::front() and list::back() in C++ STL
Lists are containers used in C++ to store data in a non-contiguous fashion, Normally, Arrays and Vectors are contiguous in nature, therefore the insertion and deletion operations are costlier as compared to the insertion and deletion option in Lists....
read more
Modifiers for Vector in C++ STL
Click here for Set 1 of Vectors....
read more
Design a stack that supports getMin() in O(1) time and O(1) extra space
Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return minimum element from the SpecialStack. All these operations of SpecialStack must have a time and space complexity of O(1). Note: To implement SpecialStack, you should only use standard Stack data structure and no other data structure like arrays, lists, etc...
read more
Initialize a vector in C++ (7 different ways)
The following are different ways to construct or initialize a vector in C++ STL...
read more
Vector in C++ STL
Vectors are the same as dynamic arrays with the ability to resize themselves automatically when an element is inserted or deleted, with their storage being handled automatically by the container. Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators. In vectors, data is inserted at the end. Inserting at the end takes differential time, as sometimes the array may need to be extended. Removing the last element takes only constant time because no resizing happens. Inserting and erasing at the beginning or in the middle is linear in time....
read more
How to Find First Occurrence of an Element in a List in C++?
In C++, the list is a sequence container that stores data in non-contiguous memory allocation. It is defined in the STL (Standard Template Library) inside the <list> header. In this article, we will learn how to find the first occurrence of a specific element in a list in C++....
read more
How to Find First Occurrence of an Element in a Deque in C++?
In C++, deques also known as double-ended queues are sequence containers with the feature of insertion and deletion on both ends. In this article, we will learn how to find the first occurrence of a specific element in a deque in C++....
read more
How to Find Last Occurrence of an Element in a Deque in C++?
In C++, deques also known as double-ended queues are sequence containers that allow the users to insert and delete elements from both ends efficiently. In this article, we will learn how to find the last occurrence of a specific element in a deque in C++....
read more
How to Remove an Element from Front of Deque in C++?
In C++, a deque (double-ended queue) is a data structure that allows efficient insertion and deletion at both ends. In this article, we will learn to remove an element from the beginning of a deque in C++....
read more