We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9b0d38e commit d021c98Copy full SHA for d021c98
solution/023.Merge k Sorted Lists/README.md
@@ -83,6 +83,21 @@ class Solution {
83
#### CPP
84
85
```C++
86
+class compare
87
+{
88
+public:
89
+ bool operator()(ListNode *l1,ListNode *l2){
90
+ //if(!l1 || !l2)
91
+ // return !l1;
92
+
93
+ if(l1 == NULL)return 1;
94
+ if(l2 == NULL)return 0;
95
+ return l1->val > l2->val;
96
+ //这里比较的是优先级,默认优先级排序是“<”号,若 l1Val > l2Val 返回真,即表示l1优先级比l2小,l2先入队
97
+ //队列的top()函数指的就是优先级最高的元素,即队头元素
98
+ }
99
+};
100
101
class Solution{
102
public:
103
ListNode* mergeKLists(vector<ListNode*>& lists) {
0 commit comments