Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Linked List Remove Duplicate Nodes
public class LinkedList<T> {
// Reference to the head node
Node head;
public void removeDuplicates(){
// check if list empty
if(head == null) return;
// chech if single node
if( == null) return;
// get head reference
Node tmp = head;
// iterate list
while( != null){
if( =={
// if duplicate remove and check with next =;
} else {
// or go to next node
tmp =;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment