We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Between Two Sets
Between Two Sets
Sort by
recency
|
2883 Discussions
|
Please Login in order to post a comment
C# Solution:
The idea is to find values x for which the following conditions apply:
x % a[i] == 0
b[j] % x ==0
In the example,
a=[2,6]
andb=[24,36]
, either 6 or 12 satisfy both conditions. Note that x cannot be smaller than the max value in a, as the minimum divisor of a number is the number itself. Likewise, x cannot be larger than the min value in b.Python
Iterative solution:
Using list comprehension
C# solution 2
C# solution