版权声明:原创勿转 https://cloud.tencent.com/developer/article/1412876
简单的循环,删除节点
func deleteDuplicates(head *ListNode) *ListNode {
cur := head
for cur != nil && cur.Next != nil {
if cur.Next.Val == cur.Val {
cur.Next = cur.Next.Next
} else {
cur = cur.Next
}
}
return head
}