83. Remove Duplicates from Sorted List
问题
Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.
设置前一个节点和当前节点两个指针。
由于是有数的链表,遍历时可以直接比较两个节点。
如相等则前一个节点的next指向当前节点的next。
1 | /** |
83. Remove Duplicates from Sorted List
https://xuanhe95.github.io/2022/04/10/83-Remove-Duplicates-from-Sorted-List/