set count() function in C++ STL
The set::count() is a built-in function in C++ STL which returns the number of times an element occurs in the set. It can only return 1 or 0 as the set container contains unique elements only.
Parameters: The function accepts one mandatory parameter element which specifies the element whose count is to be returned.
Return Value: The function returns 1 or 0 as the set contains unique elements only. It returns 1 if the value is present in the set container. It returns 0 if it is not present in the container.
Time Complexity : Time Complexity for count function is O(log N) where N is the number of elements present in the set
Difference between count and find function in a set is count returns 0 or 1 depending upon whether element is not present or present respectively whereas find function returns a iterator pointing to the value if present else next to the last value in the set.
Below is the illustration of the above function.
11 is present in the set 18 is not present in the set