Skip to content

Conversation

Silicon27
Copy link

Refactored code to initialize vector from map directly and improved output formatting.

Fixes issue:
Formatting issues and initialization shortcuts.

Changes:

for(auto i : mp1)   //inserting map values into vector
{
    vec1.push_back(make_pair(i.first,i.second));
}

was unnecessary, as you could initialize the vector and give it all the values of the map by

vector<pair<string,int>> vec1(mp1.begin(), mp1.end());

Refactored code to initialize vector from map directly and improved output formatting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant