Rosalind第52题:Introduction to Set Operations

Problem

If  and  are sets, then their union  is the set comprising any elements in either  or ; their intersection  is the set of elements in both  and ; and their set difference  is the set of elements in  but not in .

Furthermore, if  is a subset of another set , then the set complement of  with respect to  is defined as the set . See the Sample sections below for examples.

Given: A positive integer  () and two subsets  and  of .

Return: Six sets: , , , , , and  (where set complements are taken with respect to ).

如果  和 是集合,然后是他们的联合 是一组包括的任何元件或者  要么 ; 他们的交集 是这两个元素的集合  和 ; 和它们的设置差异  是中的元素集  但不在 。

此外,如果 是另一组的集,那么补集的 关于  被定义为集合 。有关示例,请参见下面的示例部分。

给定:正整数 ()和两个子集  和  的 。

回报:六套:, , , , 和  (其中集合补码相对于 )。

Sample Dataset

10
{1, 2, 3, 4, 5}
{2, 8, 5, 10}

Sample Output

{1, 2, 3, 4, 5, 8, 10}
{2, 5}
{1, 3, 4}
{8, 10}
{8, 9, 10, 6, 7}
{1, 3, 4, 6, 7, 9}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值