![]() |
In C++ STL, Stacks are a type of container adaptor with LIFO(Last In First Out) type of working, where a new element is added at one end (top) and an element is removed from that end only. Sets are a type of associative container in which each element is unique and in some sorted order. In this article, we will learn how to create a stack of sets in C++. Example Input: Creating a Stack of Sets in C++To create a std::stack of std::set in C++, we can pass the type of the stack container to be of type std::set as a template parameter while declaration. Syntax to Declare Stack of Setstack<set<type>> myStack C++ Program to Create a Stack of SetC++
Output
myStack: Set1: 7 8 9 Set2: 4 5 6 Set3: 1 2 3 Time complexity: O(N), where N is the number of sets. |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |