Answer DE43

 
/* Puzzle D43 -- check that two arrays have all elements in common
|
|   Every element in the first array must also be in the second array,
|   and every element in the second array must be in the first array.
|   However, there may be duplicate elements in either array.
|
|   Return 1 if the conditions are met; 0 otherwise.
|
*/
int allInBoth( int sizeA, int arrA[], int sizeB, int arrB[] )
{
  if ( allPresent( sizeA, arrA, sizeB,  arrB ) != -1 )
    return 0;
  
  if ( allPresent( sizeB, arrB, sizeA, arrA ) != -1 )
    return 0;
    
  return 1;
}



Back to Puzzle Home