2021年9月12日08:53:15
2021年9月12日09:00:57

/*
public class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}*/
public class Solution {
    public ListNode Merge(ListNode list1,ListNode list2) {
        ListNode cur1 = list1;
        ListNode cur2 = list2;
        ListNode head = new ListNode(-1);
        ListNode cur3 = head;

        while(cur1 != null && cur2 != null){
            if(cur1.val > cur2.val){
                cur3.next = new ListNode(cur2.val);
                cur3 = cur3.next;
                cur2 = cur2.next;
            }
            else{
                cur3.next = new ListNode(cur1.val);
                cur3 = cur3.next;
                cur1 = cur1.next;
            }
        }

        while(cur1 != null){
            cur3.next = new ListNode(cur1.val);
            cur3 = cur3.next;
            cur1 = cur1.next;
        }
        while(cur2 != null){
            cur3.next = new ListNode(cur2.val);
            cur3 = cur3.next;
            cur2 = cur2.next;
        }
        return head.next;
    }

}