public ListNode merge(ListNode l1, ListNode l2) {
        ListNode head = null, cur = null, temp;
        while(l1 != null || l2 != null) {
        	if(l2 == null || (l1 != null && l2 != null && l1.val < l2.val)) {
        		temp = l1;
                l1 = l1.next;
        	} else {
        		temp = l2;
                l2 = l2.next;
        	}
            if(head == null) head = temp;
            if(cur != null) cur.next = temp;
            cur = temp;
        }
        return head;
    }