For every element of list2 present in hset loop inserts the element into the result
while ( n2 != null ) { if ( hset . Contains ( n2 . data ) ) { result . push ( n2 . data ) ; } n2 = n2 . next ; } return result ; } LinkedList getUnion ( Node head1 , Node head2 ) {