public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
    	LinkedList<ListNode> lists3 = new LinkedList<ListNode>();
    	int flag = 0;
    	int sum = 0;
    	ListNode pre = new ListNode(0);
    	
    	// first step
    	sum = l1.val + l2.val;
    	if (sum > 9) {
    		flag = 1;
    	}
    	else{
    		flag = 0;
    	}
    	pre.val = sum - flag*10;
    	lists3.add(pre);
    	
    	// main loop
    	while ((l1.next != null)&&(l2.next != null)){
    		l1 = l1.next;
    		l2 = l2.next;
    		sum = l1.val + l2.val + flag;
    		if (sum > 9) {
        		flag = 1;
        	}
        	else{
        		flag = 0;
        	}
    		ListNode post = new ListNode(sum - flag*10);
			pre.next = post;
			lists3.add(post);
			pre = post;
    	}
    	
    	// last step
 		if (l2.next == null) l2 = l1;
		while (l2.next != null){
			l2 = l2.next;
			sum = l2.val + flag;
			if (sum > 9) {
        		flag = 1;
        	}
        	else{
        		flag = 0;
        	}
			ListNode post = new ListNode(sum - flag*10);
			pre.next = post;
			lists3.add(post);
			pre = post;
		}
		if (flag == 1){
			ListNode post = new ListNode(1);
			pre.next = post;
			lists3.add(post);
		}
    	return lists3.element();
    }