力扣第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