# My16ms C solution, easy to understand

• ``````struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) {
struct ListNode *result = (struct ListNode *)malloc(sizeof(struct ListNode));
struct ListNode *p1, *p2;
int buff = 0, dev = 0;

{
return NULL;
}

{
return l2;
}

{
return l1;
}

p1 = result;
p1->next = NULL;
{
{

p2 = (struct ListNode *)malloc(sizeof(struct ListNode));
p2->next = NULL;
p1->next = p2;
p2->val = buff % 10;
p1 = p1->next;
dev = buff / 10;
}
{

p2 = (struct ListNode *)malloc(sizeof(struct ListNode));
p2->next = NULL;
p1->next = p2;
p2->val = buff % 10;
p1 = p1->next;
dev = buff / 10;
}
else
{

p2 = (struct ListNode *)malloc(sizeof(struct ListNode));
p2->next = NULL;
p1->next = p2;
p2->val = buff % 10;
p1 = p1->next;
dev = buff / 10;
}
}

if(dev)
{
p2 = (struct ListNode *)malloc(sizeof(struct ListNode));
p2->next = NULL;
p1->next = p2;
p2->val = dev;
}
result = result->next;
return result;
``````

}

• I 've learn a lot from your code, thanks a lot. But the first lines is unnecessary. such as

``````if(head1 == NULL && head2 == NULL)
{
return NULL;
}

{
return l2;
}