class Solution {
public:
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
long long a=0,b=0,c=0;
int i=0,y=0,j;
int aa[1000000];
while(l1!=NULL){
a=a+(l1->val)*pow(10,i);
i++;
l1=l1->next;
}
while(l2!=NULL){
b=b+(l2->val)*pow(10,y);
y++;
l2=l2->next;
}
c=a+b;
ListNode *f=NULL;
ListNode *p=NULL;
for(j=0;c!=0;j++,c/=10){
aa[j]=c%10;
ListNode *pnew=new ListNode(aa[j]);
if(f==NULL){
f=pnew;
p=pnew;
continue;
}
f->next=pnew;
f=pnew;
}
ListNode *l3 = p;
return l3;
}
};