数组交集并集

NSArray *array1 = @[@"1",@"2",@"3"];

NSArray *array2 = @[@"1",@"5",@"6"];

NSMutableSet *set1 = [NSMutableSet setWithArray:array1];

NSMutableSet *set2 = [NSMutableSet setWithArray:array2];

[set1 unionSet:set2];      //取并集后 set1中为1,2,3,5,6

[set1 intersectSet:set2];  //取交集后 set1中为1

[set1 minusSet:set2]; 

你可能感兴趣的:(数组交集并集)