Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.
(移除链表中的重复元素(所有元素只出现一次))
Example:
1. 指针遍历
在遍历过程中维护一个 p_pre 来记录重复元素之前的位置。具体实现过程如下:
1 | class Solution: |
Given a sorted linked list, delete all duplicates such that each element appear only once.
(移除链表中的重复元素(所有元素只出现一次))
Example:
在遍历过程中维护一个 p_pre 来记录重复元素之前的位置。具体实现过程如下:
1 | class Solution: |