how the work comparator function. how many time is run and how to identify which elements is compare with another element inside comparator function
Priority queue comparator
hello @vishal_sangal_123
in comparator we define logic of comparision between two elements of priority queue.
it is dependent of internal implementation of priority queue . u dont have to worry about this.
the first argument of comparator comes in first(in left) in vector and then second argument.
if u want to implement min heap
com(int a,int b){
return a>b ;
}
to implement max heap
com(int a,int b){
return a<b;
}