Map in STL is used to hash key and value. We generally see map being used for standard data types. We can also use map for pairs.
For example consider a simple problem, given a matrix and positions visited, print which positions are not visited.
(0, 1) (0, 2) (1, 2) (2, 0) (2, 1)
This article is contributed by Abhishek Rajput. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Sets of pairs in C++
- Queue of Pairs in C++ STL with Examples
- How to create an unordered_map of pairs in C++?
- Count the pairs of vowels in the given string
- Find all pairs (a,b) and (c,d) in array which satisfy ab = cd
- Implementation of lower_bound and upper_bound on Set of Pairs in C++
- Implementation of lower_bound() and upper_bound() on Map of Pairs in C++
- Priority queue of pairs in C++ (Ordered by first)
- Sorting Vector of Pairs in C++ | Set 1 (Sort by first and second)
- Check if an array can be divided into pairs whose sum is divisible by k
- Count pairs whose products exist in array
- Print all pairs in an unsorted array with equal sum
- Implementation of lower_bound() and upper_bound() in Array of Pairs in C++
- Binary search in sorted vector of pairs
- Find k pairs with smallest sums in two arrays | Set 2
- Priority queue of pairs in C++ with ordering by first and second element
- Remove first adjacent pairs of similar characters until possible
- Count pairs from two sorted arrays whose sum is equal to a given value x
- Implementation of lower_bound() and upper_bound() in Vector of Pairs in C++
- Find k ordered pairs in array with minimum difference d