Please answer this

What is this comparator…“greater” does?

hello @garganshul151
greater is inbuilt comparator defined in c++.
its definition is like ->
bool greater(datatype g1,datatype g2){
return g1 > g2;
}

why we have use greater here rather we have to find the smallest of all everytime

yeah , thats why we are using min heap to get smallest element efficiently.

i donot understand the use of ‘greater’ comparator in this code

that is a standard syntax to define min heap.
pls read this article once-> https://www.geeksforgeeks.org/priority-queue-in-cpp-stl/

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.