Driver method
public static void main ( String [ ] args ) { Integer arr1 [ ] = { 3 , 1 , 5 , 7 } ; Integer arr2 [ ] = { 8 , 2 , 5 , 3 } ; LinkedList < Integer > head1 = new LinkedList < > ( Arrays . asList ( arr1 ) ) ; LinkedList < Integer > head2 = new LinkedList < > ( Arrays . asList ( arr2 ) ) ; int x = 10 ; System . out . println ( " Count ▁ = ▁ " + countPairs ( head1 , head2 , x ) ) ; } }