Lesson 13 of 24
map மற்றும் unordered_map
10 min 35 XP
map ஒவ்வொரு key-க்கும் ஒரு value, keys வரிசைப்படுத்தப்பட்டிருக்கும் (O(log n)). unordered_map வரிசை இல்லை, ஆனால் சராசரியாக O(1). m[key]++ மூலம் எண்ணுவது மிக எளிது.
Example: edit me and press Run
Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.for (auto& [key, value] : m) என்பது C++17 structured bindings. m[key] என்று படித்தாலே, key இல்லையெனில் 0-உடன் சேர்க்கப்படும்; சோதிக்க மட்டும் count() அல்லது find() பயன்படுத்துங்கள்.