VOOZH about

URL: https://www.geeksforgeeks.org/cpp/unordered_multimap-count-function-in-c-stl/

⇱ unordered_multimap count() function in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

unordered_multimap count() function in C++ STL

Last Updated : 28 Dec, 2022

The unordered_multimap::count() is a built-in function in C++ STL that returns the number of elements in the container whose key is equal to the key passed in the parameter. Syntax: 

unordered_multimap_name.count(key)

Parameters: The function accepts a single mandatory parameter key that specifies the key whose count in the unordered_multimap container is to be returned. Return Value: It returns an unsigned integral type which denotes the number of times a key occurs in the container. 

Time Complexity: O(N) 

Below programs illustrates the above function: Program 1: 

Output:
10 occurs 2 times
20 occurs 1 times
13 occurs 0 times
30 occurs 2 times

Program 2: 

Output:
a occurs 2 times
b occurs 1 times
z occurs 0 times
r occurs 2 times
Comment