哪种算法可以减少多个列表(查找坏人)

2024-06-16 08:30:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我相信这个算法在很多领域都有使用,但是我找不到合适的名称或算法,所以这里有一个需要解决的问题:

Let's say we have a town and we want to sort out the villains, we know exactly how many there are, but we don't know them, although we have some probabilities and lists in which we know exactly how many villains it contains among other people

举个例子:

L1 -> [S1, S3, S5, S6]
L2 -> [S1, S2, S6, S5]
L3 -> [S2]
L4 -> [S2, S3]

我们知道:

^{pr2}$
  • 列表可以包含类似的元素。在
  • 名单上可以出现很多坏人

根据这个简单的例子,我们可以确定恶棍是S1。在

我能找到的类似算法是Hopcroft-Karp二部匹配(https://pypi.python.org/pypi/hopcroftkarp/1.2.3),但它似乎解决了一个类似的问题,但不是这个特定的问题。在


Tags: and算法s3havemany例子howwe