The problem is to count number of non-overlaping pairs of arrays (count all pairs of arrays such that they dont have any common elements) from given set of arrays.
For example given,
a = [1,2,3]
b = [2,3,4]
c = [6,7,8]
d = [7,10,20]
The following pairs are non-overlaping (a,c), (a,d), (b,c), (b,d) since they dont have any element in common, so the answer to this instance of problem is 4
I have an n^2 solution which computes intersection of every array with every other array, and increments the count if the intersection is empty set.
Is there an efficient way to solve this? (better than n^2)