原题链接
class Solution {public: ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { ListNode* dummy = new ListNode(-1); ListNode* cur = dummy; int t = 0; while(l1 || l2 || t){ if(l1) t += l1 -> val, l1 = l1 -> next; if(l2) t += l2 -> val, l2 = l2 -> next; ListNode* node = new ListNode(t % 10); cur -> next = node; cur = cur -> next; t /= 10; } return dummy -> next; }};