Skip to content

Instantly share code, notes, and snippets.

@linnykoleh
Created April 9, 2017 11:41
Show Gist options
  • Save linnykoleh/3047b65abadfb361efa69c3ac4616209 to your computer and use it in GitHub Desktop.
Save linnykoleh/3047b65abadfb361efa69c3ac4616209 to your computer and use it in GitHub Desktop.
public ListNode deleteDuplicates(ListNode head) {
if(head == null || head.next == null)
return head;
ListNode current = head;
while(current != null && current.next != null){
if(current.val == current.next.val){
current.next = current.next.next;
}else{
current = current.next;
}
}
return head;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment