We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d5396b9 + 0dc39c1 commit bd41935Copy full SHA for bd41935
solution/021.Merge Two Sorted Lists/Solution.py
@@ -0,0 +1,21 @@
1
+# Definition for singly-linked list.
2
+# class ListNode:
3
+# def __init__(self, x):
4
+# self.val = x
5
+# self.next = None
6
+
7
+class Solution:
8
+ def mergeTwoLists(self, l1, l2):
9
+ """
10
+ :type l1: ListNode
11
+ :type l2: ListNode
12
+ :rtype: ListNode
13
14
+ while l1 and l2:
15
+ if l1.val < l2.val:
16
+ l1.next=self.mergeTwoLists(l1.next,l2)
17
+ return l1
18
+ else:
19
+ l2.next=self.mergeTwoLists(l1,l2.next)
20
+ return l2
21
+ return l1 or l2
0 commit comments