2
public ListNode mergeKLists(ListNode[] lists) {3
if (lists == null || lists.length < 1) return null;5
// add the first chunk of linkedlist to res,6
// so later we started from index 17
ListNode res = lists[0];9
// traverse the lists and start merge by calling mergeTwo10
for (int i = 1; i < lists.length; i++) {11
res = mergeTwo(res, lists[i]);17
// leetcode 21 technics18
private ListNode mergeTwo(ListNode l1, ListNode l2) {19
if (l1 == null) return l2;20
if (l2 == null) return l1;22
if (l1.val < l2.val) {23
l1.next = mergeTwo(l1.next, l2);26
l2.next = mergeTwo(l2.next, l1);