I have come across a code where i get confused , An unordered_map is initialised like below
std::unordered_map<std::string, int> wordMap;
// Inserting elements through an initializer_list
wordMap.insert({ {"First", 1}, {"Second", 2}, {"Third", 3} } );
But what surprise me is the below code
int arr[] = { 1, 5, 2, 1, 3, 2, 1 };
unordered_map<int, int> hash;
for (int i = 0; i < n; i++)
hash[arr[i]]++;
Here i am not getting how key and value is inserted in the mao
Aucun commentaire:
Enregistrer un commentaire