2022-11-21 13:15:56 +00:00
|
|
|
#ifndef S0023_MERGE_K_SORTED_LISTS_HPP
|
|
|
|
#define S0023_MERGE_K_SORTED_LISTS_HPP
|
2022-11-14 03:40:07 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
struct ListNode {
|
|
|
|
int val;
|
2022-11-30 10:20:36 +00:00
|
|
|
ListNode *next;
|
2022-11-14 03:40:07 +00:00
|
|
|
ListNode() : val(0), next(nullptr) {}
|
|
|
|
ListNode(int x) : val(x), next(nullptr) {}
|
2022-11-30 10:20:36 +00:00
|
|
|
ListNode(int x, ListNode *next) : val(x), next(next) {}
|
2022-11-14 03:40:07 +00:00
|
|
|
};
|
|
|
|
|
2022-11-30 10:20:36 +00:00
|
|
|
class S0023 {
|
2022-11-14 03:40:07 +00:00
|
|
|
public:
|
2022-11-30 10:20:36 +00:00
|
|
|
ListNode *mergeKLists(vector<ListNode *> &lists);
|
|
|
|
ListNode *mergeTwoLists(ListNode *a, ListNode *b);
|
|
|
|
ListNode *merge(vector<ListNode *> &lists, int l, int r);
|
2022-11-14 03:40:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|