The fastest "cheating" python solution 88 ms


  • 0
    T
    class Solution(object):
        def mergeKLists(self, lists):
            wl = []
            for l in lists[:]:
                if not l:
                    lists.remove(l)
                    continue
                while l:
                    wl.append(l.val)
                    l = l.next
            wl.sort()    
            start = r = ListNode(0)
            for val in wl:
                r.next = ListNode(val)
                r = r.next
            return start.next
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.