Function to return the count of distinct absolute values present in the Linked list
static int distinctCount ( Node head_ref1 ) { Set < Integer > s = new HashSet < Integer > ( ) ; Node ptr1 = head_ref1 ; while ( ptr1 != null ) { s . add ( Math . abs ( ptr1 . data ) ) ; ptr1 = ptr1 . next ; } return s . size ( ) ; }