- 83. Remove Duplicates from Sorte
- leetcode:83. Remove Duplicates f
- 83. Remove Duplicates from Sorte
- 83. Remove Duplicates from Sorte
- 83. Remove Duplicates from Sorte
- 83. Remove Duplicates from Sorte
- 83. Remove Duplicates from Sorte
- 83. Remove Duplicates from Sorte
- 83. Remove Duplicates from Sorte
- 83. Remove Duplicates from Sorte
![](https://img.haomeiwen.com/i14611540/15317cb7220c4406.png)
思路:复制链表的head指针,依次比较当前指针的值和下一个是否相等
public ListNode deleteDuplicates(ListNode head) {
ListNode current = head;
while (current != null && current.next != null) {
if (current.val == current.next.val) {
current.next = current.next.next;
} else {
current = current.next;
}
}
return head;
}
网友评论