#include <set>
=> Header file to includeset<dataType> var
=> Initialize a setset<int, greater<int>> var
=> Stores in descending order, Custom Comparatorvar.insert(n)
=> Inserts a value, Time Complexity is O(logn)var.erase(s.begin)
=> Delete the element which iterator is pointing to, Time Complexity is O(logn)var.count(value)
=> Returns boolean 1 if element is present, 0 if not present, Time Complexity is O(logn)*var.lower_bound(n)
=> Returns a number greater than or equal to given number*var.upper_bound(n)
=> Returns a number greater than given numbervar.size()
=> Returns the size of the set, Time Complexity is O(1)var.begin()
=> Returns iterator to first element, Time Complexity is O(1)var.end()
=> Returns iterator to last element, Time Complexity is O(1)var.empty()
=> Returns boolean value true if set is empty, Time Complexity is O(1)set<int>::iterator itr = var.find(n)
=> Gives the iterator to the element "n" if it is found otherwise returns s.end()
itr++
=> Moves forward by one position*itr
=> Returns value for(auto var1 : var) {
cout << var1;
}
for (auto i = var.begin(); i != var.end(); i++) {
cout << *i;
}
var.rbegin()
gives reverse iterator from end for (auto i = var.rbegin(); i != var.rend(); i++) {
cout << *i;
}
multiset<dataType> var
var.insert(value)
for(auto var1 : var) {cout << var1; }
=> Prints all even duplicatesvar.erase(n)
=> Deletes all occurrences of this element, To delete specific give pointer to that specific elementvar.find(n)
=> Returns pointer to the first element#include <unordered_set>
=> Header file to includeunordered_set<dataType> var
=> Initializefor(auto var1 : var) {cout << var1;}
=> Prints all elements in random ordervar.insert(value)
var.find(value)
=> Returns iterator of the element if found, Returns var.end() if not foundvar.begin()
var.end()
var.count(value)
=> Returns 1 if element is present, 0 if not presentvar.size()
var.clear()
var.erase(value)
var.erase(var.begin(), var.end())
=> Erase range of elements, 2nd parameter is exclusive