Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2022 23:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.
Merge all the linked-lists into one sorted linked-list and return it"""
def merge_k_lists(lists):
:type lists: List[ListNode]
:rtype: ListNode
if not lists:
return None
dummy = ListNode(0)
curr = dummy
while lists:
min_node = min(lists, key=lambda x: x.val) = min_node
curr =
min_node =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment