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.
1 parent 96c84ba commit 2180748Copy full SHA for 2180748
python/21-Merge-Two-Sorted-Lists.py
@@ -4,22 +4,22 @@
4
# self.val = val
5
# self.next = next
6
class Solution:
7
- def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
+ def mergeTwoLists(self, list1: ListNode, list2: ListNode) -> ListNode:
8
dummy = ListNode()
9
tail = dummy
10
11
- while l1 and l2:
12
- if l1.val < l2.val:
13
- tail.next = l1
14
- l1 = l1.next
+ while list1 and list2:
+ if list1.val < list2.val:
+ tail.next = list1
+ list1 = list1.next
15
else:
16
- tail.next = l2
17
- l2 = l2.next
+ tail.next = list2
+ list2 = list2.next
18
tail = tail.next
19
20
- if l1:
21
22
- elif l2:
23
+ if list1:
+ elif list2:
24
25
return dummy.next
0 commit comments