Buckle force on the 12th day - Consolidated k sort list

Violence Act

class Solution:
    def mergeKLists(self, lists: List[ListNode]) -> ListNode:
        m=[]
        head=point=ListNode(0)
        for i in lists:
            while i:
                m.append(i.val)
                i=i.next
        m.sort()
        for i in m:
            point.next=ListNode(i)
            point=point.next
        return head.next
Published 11 original articles · won praise 0 · Views 191

Guess you like

Origin blog.csdn.net/yifeng113/article/details/104819291