## The Dream Of leozp

try my best

/**
* struct ListNode {
*     int val;
*     ListNode *next;
*     ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
if (l1 == NULL){
return l2;
}
if (l2 == NULL){
return l1;
}
ListNode *ans = l1;
int cur = 0;
ListNode *p=l1;
while (l1 && l2){
int temp = l1->val + l2->val + cur;
l1->val = temp % 10;
cur = temp / 10;
p = l1;
l2 = l2->next;
if (l1->next == NULL && l2!=NULL){
l1->next = new ListNode(0);
l1 = l1->next;
break;

}
l1 = l1->next;
}
if (l1 == NULL && l2 == NULL && cur){
ListNode * ff = ans;
while (ff->next != NULL){
ff = ff->next;
}
ff->next = new ListNode(1);

}

else if (l2!=NULL){
while (l2 != NULL){
int temp = cur + l2->val;

l1->val = temp % 10;
cur = temp / 10;
l2 = l2->next;
p = l1;

l1->next = new ListNode(0);
l1 = l1->next;

}
if (cur){
l1->val = 1;
}
}
else if (l1!=NULL)
while(l1 != NULL){

int temp = cur  + l1->val;
l1->val = temp % 10;
cur = temp /= 10;
p = l1;

if (l1->next == NULL &&  cur){
l1->next = new ListNode(cur);
l1->next->val = cur;
l1 = l1->next;
break;

}

l1 = l1->next;

}
//  cout << ans->val << " " << ans->next->val << endl;
//cout << "fuck" << p->val << endl;

if (p->next && p->next->val == 0){
p->next = NULL;
}
return ans;
}
};

10-24 4867

11-21 2942

06-04 2255

06-27 1247

11-16 480

05-01 612

06-01 2336

02-27 6203

03-31 1729

03-21 523