Quickly find subset of list of lists with greatest total distinct elements
问题 Given a list of lists of tuples, I would like to find the subset of lists which maximize the number of distinct integer values without any integer being repeated. The list looks something like this: x = [ [(1,2,3), (8,9,10), (15,16)], [(2,3), (10,11)], [(9,10,11), (17,18,19), (20,21,22)], [(4,5), (11,12,13), (18,19,20)] ] The internal tuples are always sequential --> (1,2,3) or (15,16), but they may be of any length. In this case, the expected return would be: maximized_list = [ [(1, 2, 3),