You’ve N elements and you need to find the subsets of these N elements where zero or more of the N elements are included or excluded.
Pair in C++ STL is used to combine two values having different or same data types. It stores two different values as a single element. Tuple unlike pair can be used to combine two or more than two values having different or same data types.
Internally, the elements in the unordered_map are not sorted in any particular order with respect to either their key or values (unlike map)
Stacks and queues are data structures that store elements of a specific data type. They have various operations (methods/functions) to input, output and manage the data. Stack implements a lastin, first-out (LIFO) policy on its elements. So, the element removed from the stack is always the most recently inserted one. On […]
The Heap data structure is an array that can be viewed as a complete Binary Tree. Each node in the tree corresponds to an element of the array A. We already discussed Heap data structure in this – post. However in this post we would learn about, how to build min/max Heaps […]
A vector is a data structure for maintaining a set of elements having a specific data type. Vectors can be considered as arrays having dynamic size. Just like arrays, vectors also store its elements in a contiguous storage locations. That is why, elements in a vector can be accessed using offsets […]
Given a string s1, find the occurrences of string s2 in s1. Example 1: Input: s1 = “superhero”; s2 = “hero” Output: hero found at 5th position Explanation: “hero” is substring of “superhero”. Example 2: Input: s1 = “onlycode”; s2 = “code” Output: code found at 4th position Explanation: “code” is […]
In the last post we discussed about C++ Standard Template Library (STL) Linked List. In this post we would learn about STL Priority queue and using it as Max/Min Heap. Priority Queue A priority queue is a data structure for maintaining a set of elements having an associated value. Priority Queue […]
The C++ Standard Template Library (STL) is a powerful library of C++ template classes that provide general-purpose classes and functions. It has implementations of many popular and commonly used algorithms and data structures like vectors, linked-lists, queues, priority queues, and stacks. In this post we’ll learn about: linked-lists. Linked List To […]