public static ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        ListNode node, p = null, l3 = null;

        if (l1 == null) {
            l3 = l2;
        } else if (l2 == null) {
            l3 = l1;
        } else {
            while (l1 != null && l2 != null) {
                if (l1.val <= l2.val) {
                    node = l1;
                    l1 = l1.next;
                } else {
                    node = l2;
                    l2 = l2.next;
                }

                if (l3 == null) {
                    l3 = node;
                    p = l3;
                } else {
                    p.next = node;
                    p = node;
                }
            }

            if (l1 != null) {
                node = l1;
                l1 = l1.next;
                p.next = node;
                p = node;
            }

            if (l2 != null) {
                node = l2;
                l2 = l2.next;
                p.next = node;
                p = node;
            }
        }

        return l3;
    }