HashMap that will store the elements of the lists with their counts
HashMap < Integer , Integer > hmap = new HashMap < > ( ) ; Node n1 = head1 ; Node n2 = head2 ; LinkedList result = new LinkedList ( ) ;