+ 1
Can we have multiple values in a vector for same index?
Is it possible to store multiple values for same key in a vector? If yes, How they will be stored?
2 Réponses
+ 3
Anubhav Singh it's not vector which are designed to take key...map is the one having key...once you try to duplicate key, value gets updated
0
you can store the value inside a collection like an array or list and that would be something like:
map<int, list<int>> a; or
map<int, array<int, n>> a;
reminder you would still need to access different values by index