From 42f7181ba900c87d7cb2f739c15f0698caee7936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A5=E6=96=87?= Date: Fri, 21 Aug 2020 14:38:16 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E9=93=BE=E8=A1=A8.md(=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=93=BE=E8=A1=A8=E6=B1=82=E5=92=8C=E4=BB=A3=E7=A0=81?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notes/Leetcode 题解 - 链表.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/notes/Leetcode 题解 - 链表.md b/notes/Leetcode 题解 - 链表.md index 5ccf66fc..6beb0ad3 100644 --- a/notes/Leetcode 题解 - 链表.md +++ b/notes/Leetcode 题解 - 链表.md @@ -1,14 +1,14 @@ -* [1. 找出两个链表的交点](#1-找出两个链表的交点) -* [2. 链表反转](#2-链表反转) -* [3. 归并两个有序的链表](#3-归并两个有序的链表) -* [4. 从有序链表中删除重复节点](#4-从有序链表中删除重复节点) -* [5. 删除链表的倒数第 n 个节点](#5-删除链表的倒数第-n-个节点) -* [6. 交换链表中的相邻结点](#6-交换链表中的相邻结点) -* [7. 链表求和](#7-链表求和) -* [8. 回文链表](#8-回文链表) -* [9. 分隔链表](#9-分隔链表) -* [10. 链表元素按奇偶聚集](#10-链表元素按奇偶聚集) +- [1. 找出两个链表的交点](#1-找出两个链表的交点) +- [2. 链表反转](#2-链表反转) +- [3. 归并两个有序的链表](#3-归并两个有序的链表) +- [4. 从有序链表中删除重复节点](#4-从有序链表中删除重复节点) +- [5. 删除链表的倒数第 n 个节点](#5-删除链表的倒数第-n-个节点) +- [6. 交换链表中的相邻结点](#6-交换链表中的相邻结点) +- [7. 链表求和](#7-链表求和) +- [8. 回文链表](#8-回文链表) +- [9. 分隔链表](#9-分隔链表) +- [10. 链表元素按奇偶聚集](#10-链表元素按奇偶聚集) @@ -227,6 +227,12 @@ public ListNode addTwoNumbers(ListNode l1, ListNode l2) { head.next = node; carry = sum / 10; } + if (carry != 0) { + // 对于用例: [5], [5] --> [1, 0] + ListNode node = new ListNode(carry); + node.next = head.next; + head.next = node; + } return head.next; }