Skip to main content

multimap

ALL methods are same as map & unordered_map except [] , .at() no available.

caution

multimap don't have [] or .at().

MUST USE insert(pair{..,..}) to add elements to multimap

insert(pair{..,..}) - to add elements to the multimap

mp.insert(pair{distance, el});

vector<vector<int>> kClosest(vector<vector<int>>& points, int k) {
multimap<double, vector<int>> mp;
for(auto& el:points) {
double distance = sqrt(pow((el[0]-0), 2) + pow((el[1]-0),2));

mp.insert(pair{distance, el}); // multimap dont have [] or .at()
}