Skip to content

Commit c2689a9

Browse files
committed
Refactor : use list1&& list2 instead make new instance
1 parent 929ae16 commit c2689a9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

merge-two-sorted-lists/sungjinwi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) ->
2323

2424
while list1 and list2 :
2525
if list1.val < list2.val :
26-
node.next = ListNode(list1.val)
26+
node.next = list1
2727
list1 = list1.next
2828
else :
29-
node.next = ListNode(list2.val)
29+
node.next = list2
3030
list2 = list2.next
3131
node = node.next
3232
node.next = list1 or list2

0 commit comments

Comments
 (0)