Skip to content

Instantly share code, notes, and snippets.

@Ahmah2009
Created April 6, 2019 11:51
Show Gist options
  • Save Ahmah2009/2aefab238d3baae7d49549c7f1372866 to your computer and use it in GitHub Desktop.
Save Ahmah2009/2aefab238d3baae7d49549c7f1372866 to your computer and use it in GitHub Desktop.
82. Remove Duplicates from Sorted List II leetcode
func deleteDuplicates(head *ListNode) *ListNode {
if head == nil{
return head
}
tempNode := &ListNode{Val: head.Val-1, Next:head}
node:=tempNode
fast := tempNode.Next
for node.Next!=nil && fast.Next!=nil{
if fast.Val ==fast.Next.Val{
temp := fast
for temp!=nil && temp.Val ==fast.Val{
temp=temp.Next
}
node.Next=temp
fast= temp
}else{
node = node.Next
fast = fast.Next
}
}
return tempNode.Next
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment