Over and Out , One loop solution


#1
ListNode* Solution::addTwoNumbers(ListNode* A, ListNode* B) {
   ListNode* h1=NULL,*t1=NULL;
   int c=0; //carry
   while(A or B or c){
       int v1=0,v2=0;
       if(A)v1=A->val,A=A->next;
       if(B)v2=B->val,B=B->next;
       c+=v1+v2;
       ListNode* tmp=new ListNode(c%10);
       if(!h1)h1=tmp,t1=tmp;
       else t1->next=tmp,t1=t1->next;
       c/=10;
   }
   return h1;
}