12日のバックル力 - 連結k個のソートリスト

暴力行為

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
公開された11元の記事 ウォンの賞賛0 ビュー191

おすすめ

転載: blog.csdn.net/yifeng113/article/details/104819291