Elements of an array that are not divisible by any element of another array

Revision en1, by wish_me, 2017-10-09 00:35:35

Given two arrays A[] and B[], write an efficient code to determine if every element of B[] is divisible by at least 1 element of A[]. Display those elements of B[], which are not divisible by any of the element in A[].

Examples:

Input : A[] = {100, 200, 400, 100, 600}

B[] = {45, 90, 48, 1000, 3000}

Output : 45, 90, 48

The output elements are those that are

not divisible by any element of A[].

n<10^5 arr.size<10^5

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English wish_me 2017-10-09 00:35:35 522 Initial revision (published)