본문 바로가기
Coding Test/C++ 줍줍

[C++ 줍줍] Map의 value에 여러 개의 값을 저장하기

by seoyamin 2022. 7. 5.

▷ 문제 상황

   key와 value로 이루어진 Map에서 value에 여러개의 값을 저장하고 싶다!

 

 

▶ 해결 방법

   value에 vector를 넣어줄 수 있다!

 

 

정의하는 형식 )

map<key, vector<datatype>> map_of_vector;

OR

map<vector<datatype>, key> map_of_vector;

 

 

 

 

 

[참고자료]  https://www.geeksforgeeks.org/map-of-vectors-in-c-stl-with-examples/

 

Map of Vectors in C++ STL with Examples - GeeksforGeeks

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

www.geeksforgeeks.org