> For the complete documentation index, see [llms.txt](https://nataliekung.gitbook.io/solutions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nataliekung.gitbook.io/solutions/merge_k_sorted_lists/merge_sort.md).

# merge sort

public class Solution {

public ListNode mergeKLists(ListNode\[] lists) {

if(lists==null || lists.length==0) return null;

return helper(lists,0,lists.length-1);

}

public ListNode helper(ListNode\[] lists, int s, int e){

if(s==e)

return lists\[s];

int m=(s+e)/2;

return merge(helper(lists,s,m),helper(lists,m+1,e));

}

}
