Skip to content

Commit

Permalink
refactor: feat: 21. Merge Two Sorted Lists
Browse files Browse the repository at this point in the history
  • Loading branch information
gwbaik9717 committed Jan 1, 2025
1 parent ca72dd4 commit 0cdbba8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions merge-two-sorted-lists/gwbaik9717.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,12 @@ var mergeTwoLists = function (list1, list2) {
current = current.next;
}

while (list1) {
current.next = new ListNode(list1.val);
list1 = list1.next;
current = current.next;
if (list1) {
current.next = list1;
}

while (list2) {
current.next = new ListNode(list2.val);
list2 = list2.next;
current = current.next;
if (list2) {
current.next = list2;
}

return answer.next;
Expand Down

0 comments on commit 0cdbba8

Please sign in to comment.