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 linked list.
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
class Solution {
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
ListNode p1 = l1;
ListNode p2 = l2;
ListNode head = new ListNode(0);
ListNode p3 = head;
int add_value=0;

这篇博客介绍了如何解决LeetCode中的一个问题——将两个表示非负数的逆序链表相加,返回结果依然为逆序链表。具体题目中,输入为2->4->3和5->6->4,输出为7->0->8。
订阅专栏 解锁全文
272

被折叠的 条评论
为什么被折叠?



