Link to my Code : https://ide.codingblocks.com/s/186063
I have sucessfully submitted the problem but i am unable to understand the signs of the compartor function.
Why can’t this work :
struct comp {
bool operator() (const ppi a,const ppi b) {
if(a.S == b.S)
return a.F < b.F;
return a.S>b.S;
}
};
As here for Min Heap , we want the smallest of the two numbers when they are of same frequency. So why this is Wrong and reversing the signs lead to correct answer?