You are given two linked lists representing two non-negative numbers. The digits are stored in reverse orderand each of their nodes contain a single digit. Add the two numbers andreturn it as a linked list.
Input: (2-> 4-> 3) + (5-> 6-> 4)
Output: 7-> 0-> 8
有两个链表作为输入,它们表示逆序的两个非负数。如下面的两个链表表示的是342和465这两个数。你需要计算它们的和并且用同样的方式逆序输出。如342+465=807,你需要把结果表达为7->0->8
作为节点的话,就得先来个节点类了
publicclass ListNode {
int val;
ListNode next;
ListNode(int x) { val = x; }
}
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linke