@@ -0,0 +1,1243 @@
+package leetcode;%0A%0Apublic class Task21 %7B%0A%0A    public static class ListNode %7B%0A        int val;%0A        ListNode next;%0A%0A        ListNode(int x) %7B%0A            val = x;%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        ListNode head1 = new ListNode(1);%0A        head1.next = new ListNode(2);%0A        head1.next.next = new ListNode(4);%0A%0A        ListNode head2 = new ListNode(1);%0A        head2.next = new ListNode(3);%0A        head2.next.next = new ListNode(4);%0A%0A        new Task21().mergeTwoLists(head1, head2);%0A    %7D%0A%0A    public ListNode mergeTwoLists(ListNode l1, ListNode l2) %7B%0A        ListNode preHead = new ListNode(0);%0A        ListNode tail = preHead;%0A        while (l1 != null %7C%7C l2 != null) %7B%0A            int v1 = l1 != null ? l1.val : Integer.MAX_VALUE;%0A            int v2 = l2 != null ? l2.val : Integer.MAX_VALUE;%0A            if (v1 %3C v2) %7B%0A                tail = addNode(tail, v1);%0A                l1 = l1.next;%0A            %7D else %7B%0A                tail = addNode(tail, v2);%0A                l2 = l2.next;%0A            %7D%0A        %7D%0A        return preHead.next;%0A    %7D%0A%0A    private ListNode addNode(ListNode tail, int val) %7B%0A        ListNode next = new ListNode(val);%0A        tail.next = next;%0A        return next;%0A    %7D%0A%7D%0A

Add Task21