Open In App

How to swap Keys with Values of a Map in C++?

Given a map, the task is to swap the Keys of this map with its values, in C++.

Examples:



Input: map =
    {'e', 1 },
    {'o', 1 },
    {'r', 3 },
    
Output:
    {1, 'e' },
    {1, 'o' },
    {3, 'r' },

Article Tags :