Function to remove duplicates
static void removeDuplicates ( Node head ) { HashMap < Integer , Boolean > track = new HashMap < > ( ) ; Node temp = head ; while ( temp != null ) { if ( ! track . containsKey ( temp . data ) ) { System . out . print ( temp . data + " ▁ " ) ; } track . put ( temp . data , true ) ; temp = temp . next ; } }