In this article we will discuss how to find an element in an unordered_map.

An unordered_map store elements in key – value pair. Hence to search an element we need to search if the key exists in an unordered_map or not. For this unordered_map provides a member function find() i.e.

It accepts a key as an argument and returns an iterator i.e.

If the given key exists in map then, it will return an iterator pointing to the element. Otherwise, iterator pointing to the end of map.

Let’s see an example,

Ouput:

 

 

Join LinkedIn Group of Python Professional Developers who wish to expand their network and share ideas.

You can also follow us On Twitter :

Click Here to Subscribe for more Articles / Tutorials like this.