public void DeleteDuplicates()
{
if (this.Head == null)
{
return;
}
LinkedListNode curr = this.Head;
LinkedListNode next = curr.Next;
while (next != null)
{
if (next.Value == curr.Value)
{
while(next != null && next.Value == curr.Value)
{
next = next.Next;
}
}
curr.Next = next;
curr = next;
if (next != null)
{
next = next.Next;
}
}
}
No comments:
Post a Comment