This checks whether the union of all subsets is equal to the original indices. To test whether they are disjoint you have to merge all of them and sort, and then see whether this set is equal to the original one.

Same below