美文网首页
数组交集并集

数组交集并集

作者: adalillian | 来源:发表于2020-08-03 22:38 被阅读0次

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]; 

相关文章

网友评论

      本文标题:数组交集并集

      本文链接:https://www.haomeiwen.com/subject/nojvrktx.html