The arrayGroup below will be containing almost 190,000 int arrays.
so filtering them to retrieve groups of arrays in the array group that have two or more common digits is taking forever.
I am using the linq expression below, any ideas to make this more efficient?
List<int[]> arrayGroup = new List<int[]>();
var filteredGroups = arrayGroup
.SelectMany(arr1 => arrayGroup
.Where(arr2 => arr1 != arr2) // Don't compare array to itself
.Select(arr2 => new
{
Source = arr1,
Target = arr2,
Common = arr1.Intersect(arr2).Distinct().Count()
})
)
.Where(match => match.Common >= 2)
.GroupBy(match => match.Source)
.Select(group => group.Key)
.ToList();