Initialize of customize priority queue:

  1. define a struct of compare function.
  2. note the init method of pq.
1
2
3
4
5
6
7
struct compare{
bool operator()(ListNode *a, ListNode *b){
return a->val> b->val;
}
};

priority_queue<ListNode*, vector<ListNode*>, compare> pq;

reference:
http://www.cplusplus.com/reference/queue/priority_queue/priority_queue/