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; } } ```