Check out example codes for "min heap priority queue with pair". It will help you in understanding the concepts better.

Code Example 1

priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>> > Q;

Learn ReactJs, React Native from akashmittal.com