ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {

int count = 0;

ListNode* ptr = l1;

ListNode* ls = ptr;

if (l1 == nullptr)

return l2;

while (l2 != nullptr)

{

if (ptr == nullptr)

{

int kk = l2->val + count;

count = kk / 10;

l2->val = kk % 10;

ls->next = l2;

l2 = l2->next;

ls = ls->next;

break;

}

else

{

int kk = ptr->val + l2->val + count;

count = kk / 10;

ptr->val = kk % 10;

ls = ptr;

ptr = ptr->next;

l2 = l2->next;

}

```
}
while (count != 0)
{
if (ls->next == nullptr)
{
ListNode p(count);
ls->next = &p;
count = 0;
}
else
{
int kk = ls->next->val + count;
count = kk / 10;
ls->next->val = kk % 10;
ls = ls->next;
}
}
return l1;
}
```