Skip to content

Instantly share code, notes, and snippets.

@Ahmah2009
Created April 6, 2019 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ahmah2009/0c0a9b627157a3a023944a684bd52477 to your computer and use it in GitHub Desktop.
Save Ahmah2009/0c0a9b627157a3a023944a684bd52477 to your computer and use it in GitHub Desktop.
83. Remove Duplicates from Sorted List leetcode
func deleteDuplicates(head *ListNode) *ListNode {
if head == nil {
return head
}
node:=head
next := head.Next
for node!=nil && next!=nil{
if node.Val==next.Val{
temp := next
for temp!=nil && temp.Val==next.Val{
temp=temp.Next
}
node.Next= temp
}
node= node.Next
if node == nil {
break
}
next = node.Next
}
return head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment