To pick next pair , traverse for all elements of arr1 [ ] , for every element , find corresponding current element in arr2 [ ] and pick minimum of all formed pairs .
for ( int i1 = 0 ; i1 < n1 ; i1 ++ ) {