class Solution:
def mergeKLists(self, lists: List[ListNode]) -> ListNode:
a=[]
for l in lists:
h=l
while h:
a.append(h.val)
h=h.next
a.sort()
n=len(a)
if n==0:
return
h=ListNode(a[0])
ans=h
for i in range(1,n):
h.next=ListNode(a[i])
h=h.next
return ans
336

被折叠的 条评论
为什么被折叠?



