In this article we will see how to search if an element is present in an unordered_set or not.

std::unordered_set provides a member function find () that accepts an element of same type as set and search for that element in set.

If element is found then it returns the iterator pointing to that element else it returns an iterator pointing to end of set i.e. unordered_set::endl().

Let’s see an example,

In the above example we tried to search for the 2 elements in set, one was present and other was not.



Python Recommendations:

C++ & C++11 Recommendations:

If you didn't find what you were looking, then do suggest us in the comments below. We will be more than happy to add that.

Subscribe with us to join 1500+ Python & C++ developers, to get more Tips &  Tutorials like this.