Created
April 6, 2019 12:26
-
-
Save Ahmah2009/0c0a9b627157a3a023944a684bd52477 to your computer and use it in GitHub Desktop.
83. Remove Duplicates from Sorted List leetcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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