unordered_set
unsorted set with operations O(1)
setbasic opeartions are ofO(log n); whereasunordered_setbasic opeartions are ofO(1),
caution
Unordered sets work with primitive types, but require a [custom hash function- use us_gu] for structures/classes like vectors and pairs.
info
Use case for unordered_set
- check element present or not
caution
Only take basic primitive data types such as
int,string,float,bool,long long,double
Cannot take other complex containers like:~
set<int>< pair < int, int > >
Lookup Functions
count()
find()
caution
Time Complexity:
- Average case: constant --
O(1) - Worst case: linear in container size -- --
O(n)
contains()
dont'have lower_bound nd upper_bound
unodered_set has no member lower_bound or upper_bound