Lesson 13 of 24
map మరియు unordered_map
10 min 35 XP
map ప్రతి key కు value ను నిల్వ చేస్తుంది, keys sorted గా ఉంటాయి (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() వాడండి.