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 ca72dd4 commit 0cdbba8Copy full SHA for 0cdbba8
merge-two-sorted-lists/gwbaik9717.js
@@ -30,16 +30,12 @@ var mergeTwoLists = function (list1, list2) {
30
current = current.next;
31
}
32
33
- while (list1) {
34
- current.next = new ListNode(list1.val);
35
- list1 = list1.next;
36
- current = current.next;
+ if (list1) {
+ current.next = list1;
37
38
39
- while (list2) {
40
- current.next = new ListNode(list2.val);
41
- list2 = list2.next;
42
+ if (list2) {
+ current.next = list2;
43
44
45
return answer.next;
0 commit comments