LeetCode题目 代码实现:GO语言
func deleteDuplicates(head
*ListNode
) *ListNode
{
if head
==nil{
return head
}
slow
:=head
fast
:=head
for fast
!=nil{
if fast
.Val
!=slow
.Val
{
slow
.Next
=fast
slow
=slow
.Next
}
fast
=fast
.Next
}
slow
.Next
=nil
return head
}
解题思路:类似快慢指针 同26题
转载请注明原文地址:https://blackberry.8miu.com/read-8230.html