I was trying to create a minHeap using the regular syntax but found out that
maxHeap is initialised as:
priority_queue<int> maxHeap;
whereas minHeap is initailised as:
priority_queue<int, vector<int>, greater<int>> minHeap;
Any idea to why is it so in C++? It could have been much easier to remember if minHeap and maxHeap were initialised using similar syntax.
The priority_queue defaults to a max heap, so
priority_queue<int>
is shorthand forpriority_queue<int, vector<int>, less<int>>
, which does indeed match the min heap syntax