data = [[0,1], [1,6,10], [], [1,2,4,5], [7,8], [], [], [8], [2], [0,3], [9]]
Given the above 2d array, I need to select five arrays that give me the most unique number.
For example
# returns 11 (optimal output, the number of subclasses)
(data[1] | data[3] | data[4] | data[9] | data[10]).length
# returns 10 (less optimal output)
(data[0] | data[1] | data[3] | data[4] | data[10]).length
Doing it the brute force way is taking way too much time to complete. Is there any other suggestion?