From d8ee3b592e6d15031e11bc3717dc8215c0d1e9af Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Wed, 28 Oct 2026 13:45:03 +0800 Subject: [PATCH] =?UTF-8?q?Update=2018.2=20=E5=88=A0=E9=99=A4=E9=93=BE?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=E9=87=8D=E5=A4=8D=E7=9A=84=E7=BB=93=E7=82=B9?= =?UTF-8?q?.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。 --- notes/18.2 删除链表中重复的结点.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/notes/18.2 删除链表中重复的结点.md b/notes/18.2 删除链表中重复的结点.md index 5d1f871b..fce005a5 100644 --- a/notes/18.2 删除链表中重复的结点.md +++ b/notes/18.2 删除链表中重复的结点.md @@ -1,6 +1,6 @@ # 18.2 删除链表中重复的结点 -[牛客网](https://www.nowcoder.com/practice/fc533c45b73a41b0b44ccba763f866ef?tpId=13&tqId=11209&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) +[Leetcode](https://leetcode.cn/problems/remove-duplicates-from-sorted-list-ii/) ## 题目描述 @@ -9,17 +9,17 @@ ## 解题描述 ```java -public ListNode deleteDuplication(ListNode pHead) { - if (pHead == null || pHead.next == null) - return pHead; - ListNode next = pHead.next; - if (pHead.val == next.val) { - while (next != null && pHead.val == next.val) +public ListNode deleteDuplicates(ListNode head) { + if (head == null || head.next == null) + return head; + ListNode next = head.next; + if (head.val == next.val) { + while (next != null && head.val == next.val) next = next.next; - return deleteDuplication(next); + return deleteDuplicates(next); } else { - pHead.next = deleteDuplication(pHead.next); - return pHead; + head.next = deleteDuplicates(head.next); + return head; } } ```