vector of map?

how to create a vector of maps and how to store values in it and how to print those values??

vector< map< string, int > > v;
for( int i = 0; i < 5; ++i )
{
map< string, int > temp;
temp.insert( make_pair( β€œ1”, i );
temp.insert( make_pair( β€œ2”, i );
v.emplace_back( temp );
}
foreach( auto& a : v )
{
foreach( auto& m : a )
{
cout << "key : " << a.first << " value : " << a.second << β€œ\n”;
}
cout << β€œnext\n”;
}

you did not mention what language, so I made it in C++

1 Like

Thanks for sharing this @flaze07!!