Compare commits
No commits in common. "c72996f34290d4b26dabd7f08d516d665eae494a" and "95ea49c5a0fd6caa3bf394bbe81d7e1e6a70e1e6" have entirely different histories.
c72996f342
...
95ea49c5a0
|
|
@ -1,20 +0,0 @@
|
||||||
package solution;
|
|
||||||
|
|
||||||
public class ListNode {
|
|
||||||
int val;
|
|
||||||
ListNode next;
|
|
||||||
|
|
||||||
ListNode() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ListNode(int val) {
|
|
||||||
this.val = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
ListNode(int val, ListNode next) {
|
|
||||||
this.val = val;
|
|
||||||
this.next = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -204,26 +204,4 @@ public class Solution {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
|
|
||||||
ListNode dummy = new ListNode(0);
|
|
||||||
ListNode current = dummy;
|
|
||||||
while (list1 != null && list2 != null) {
|
|
||||||
if (list1.val < list2.val) {
|
|
||||||
current.next = list1;
|
|
||||||
list1 = list1.next;
|
|
||||||
} else {
|
|
||||||
current.next = list2;
|
|
||||||
list2 = list2.next;
|
|
||||||
}
|
|
||||||
current = current.next;
|
|
||||||
}
|
|
||||||
if (list1 != null){
|
|
||||||
current.next = list1;
|
|
||||||
} else if (list2 != null){
|
|
||||||
current.next = list2;
|
|
||||||
}
|
|
||||||
return dummy.next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue