MCPcopy Index your code
hub / github.com/HuberTRoy/leetCode / mergeTwoLists

Method mergeTwoLists

Array/MergerTwoSortedList.py:21–42  ·  view source on GitHub ↗

:type l1: ListNode :type l2: ListNode :rtype: ListNode

(self, l1, l2)

Source from the content-addressed store, hash-verified

19class Solution(object):
20
21 def mergeTwoLists(self, l1, l2):
22 """
23 :type l1: ListNode
24 :type l2: ListNode
25 :rtype: ListNode
26 """
27
28 head = cur = ListNode(0)
29
30 while l1 and l2:
31 if l1.val < l2.val:
32 cur.next = l1
33 l1 = l1.next
34 else:
35 cur.next = l2
36 l2 = l2.next
37
38 cur = cur.next
39
40 cur.next = l1 or l2
41
42 return head.next

Callers

nothing calls this directly

Calls 1

ListNodeClass · 0.85

Tested by

no test coverage detected