![]() |
In C++, the Standard Template Library (STL) provides a container called deque that allows efficient insertion and deletion operations at both ends of the container. A map is an associative container that stores elements in key-value pairs.In this article, we will learn how to create a deque of maps in C++. Example Input: myMap1: {1: "C++", 2: "Python"} myMap2: {1: "Java", 3: "Javascript"} Output: myDeque: [ {1: "C++", 2: "Python"}, {1: "Java", 3: "Javascript"} ] Create a Deque of Maps in C++To create a std::deque of std::maps in C++, we have to define the type of the deque element as std::map in the deque declaration as shown in the below syntax: Syntax to Create a Deque of Maps in C++deque<map<KeyType, ValueType>> deque_Name;
C++ Program to Create a Deque of MapsThe following program illustrates how to create a deque of maps in C++:
Output Deque Elements: Map1 { {1, C++} {2, Java} } Map2 { {1, JavaScript} {2, Python} } Time Complexity: O(N*M)where N is the number of elements in the map. |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |