Priority queue greater as function

What does greater do when declare the priority queue to convert it into min heap? How is it helping to convert it into min heap?

@govilayush it is the comparator that the STL uses to put the elements inside the heap. It is a either a max heap or a min heap depending on this comparator. By default it is a max heap and if we provide the greater comparator it behaves like a min heap.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.