What is priority_queue STL in C++?
A ‘priority_queue‘ is a container adaptor that provides us with a constant time lookup of the largest element at the expense of logarithmic insertion and extraction. We can use a user-provided compare function to change the order e.g. using std::greater<T> would cause the smallest element to appear at the top.
When we are using the priority queue we are basically using a heap in some random access container, which has the benefit of not being able to accidentally invalidate the given heap.