我有下面的熊猫系列,我需要选择的行是其他行的超集。你知道吗
系列:
1 [72197, 82086]
2 [72197, 82086, 194665]
3 [72230]
4 [72235, 72690, 121261]
5 [72235, 121261]
6 [72241]
7 [72251]
8 [72253, 83613]
9 [72253, 83613, 101294]
10 [72255, 122794]
11 [71962, 101646, 101663, 126351]
12 [71962, 101646, 101663, 126351, 141883]
13 [71962, 101646, 101663, 141883]
14 [72235]
输出系列:
1 [72197, 82086, 194665]
2 [72230]
3 [72235, 72690, 121261]
4 [72241]
5 [72251]
6 [72253, 83613, 101294]
7 [72255, 122794]
8 [71962, 101646, 101663, 126351, 141883]
你可以试试这个:
如果排序不重要,您可以使用一种稍微改变的this解决方案—将内部列表转换为
set
的第一个和最后一个转换回:你知道吗
如果您使用普通列表,我想您可以使用set(a)<;set(b)来检查一个列表是否是另一个列表的子集。 在这里发布一个示例代码。我不确定它是否对你有用。你知道吗
相关问题 更多 >
编程相关推荐