class Solution:
def mergeKLists(self, lists):
list1=[]
for i in lists:
while i:
list1.append(i.val)
i=i.next
if list1==[]:
return []
list1.sort()
l = ListNode(0)
res = l
while list1:
l.next=ListNode(list1.pop(0))
l=l.next
return res.next
借助数组,进行排序,然后再穿成链表,开辟了数组空间,空间复杂度为O(n)