public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
		if (l1 == null && l2 == null)
			return null;

		int curSum, carry = 0;
		ListNode cur, pre, result;
		ListNode cur1 = l1;
		ListNode cur2 = l2;

		curSum = cur1.val + cur2.val;
		carry = curSum / 10;
		result = new ListNode(curSum % 10);
		pre = result;
		cur1 = cur1.next;
		cur2 = cur2.next;

		while (cur1 != null && cur2 != null) {
			curSum = cur1.val + cur2.val + carry;
			carry = curSum / 10;
			cur = new ListNode(curSum % 10);
			pre.next = cur;
			pre = cur;
			cur1 = cur1.next;
			cur2 = cur2.next;
		}

		while (cur1 != null) {
			curSum = cur1.val + carry;
			carry = curSum / 10;
			cur = new ListNode(curSum % 10);
			pre.next = cur;
			pre = cur;
			cur1 = cur1.next;
		}

		while (cur2 != null) {
			curSum = cur2.val + carry;
			carry = curSum / 10;
			cur = new ListNode(curSum % 10);
			pre.next = cur;
			pre = cur;
			cur2 = cur2.next;
		}

		if (carry == 1) {
			cur = new ListNode(1);
			pre.next = cur;
			pre = cur;
		}

		return result;

	}