Skip to content

Commit

Permalink
Refactor : use list1&& list2 instead make new instance
Browse files Browse the repository at this point in the history
  • Loading branch information
sungjinwi committed Jan 4, 2025
1 parent 929ae16 commit c2689a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions merge-two-sorted-lists/sungjinwi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) ->

while list1 and list2 :
if list1.val < list2.val :
node.next = ListNode(list1.val)
node.next = list1
list1 = list1.next
else :
node.next = ListNode(list2.val)
node.next = list2
list2 = list2.next
node = node.next
node.next = list1 or list2
Expand Down

0 comments on commit c2689a9

Please sign in to comment.