+ 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?

23rd Aug 2018, 6:23 PM
Anubhav Singh
Anubhav Singh - avatar
2 odpowiedzi
+ 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
23rd Aug 2018, 6:43 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
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
24th Aug 2018, 6:40 AM
hinanawi
hinanawi - avatar