Definition at line 17 of file main.cpp.
◆ mergeTwoLists()
Definition at line 28 of file main.cpp.
29 {
30 if (!list1 && !list2)
31 return NULL;
32 else if (!list1)
33 return list2;
34 else if (!list2)
35 return list1;
36 priority_queue<ListNode*, vector<ListNode*>, Compare> min_heap;
38 while (current != NULL)
39 {
40 min_heap.push(current);
41 current = current->
next;
42 }
43 current = list2;
44 while (current != NULL)
45 {
46 min_heap.push(current);
47 current = current->
next;
48 }
50 min_heap.pop();
51 current = head;
52 while (!min_heap.empty())
53 {
54 current->
next = min_heap.top();
55 min_heap.pop();
56 current = current->
next;
57 }
59 return head;
60 }
Definition for singly-linked list.
References ListNode::next.
The documentation for this class was generated from the following file: