是否有一种有效的方法可以仅查找v In Inter P Inter P Inter的感兴趣的组合
是否有一种有效的方法只能找到P Inted p Inter P中的V In Imption的组合,
我有类似的列表。
V = [2,3,5,7,9,12]
V的大小可以从0到50 根据我的输入。 V没有重复。
我还有另一个列表p这样的 
P = [ [1],[1,2],[2,3] [3,4], [3,5,7], [3,5,8] ...]
p是恒定的,尺寸为1000。p
没有重复项,在p中,每个元素都按升序排序。 
P中找到V中存在的V组合的一种有效方法是
。
在 BE [[2,3],[3,5,7]
。
我已经尝试从V产生所有可能的安排,然后过滤  by  nbsp;这不是很高效。只是想知道是否有更好的方法可以做我要求的。 
既然我已经知道P是任何形式的树是一个更好的选择吗?
Is there a efficient way to find only the combinations of interest from V exciting in P
I have a list of something like this.
V = [2,3,5,7,9,12]
Size of V can be anywhere from 0 to 50 based on my input.
V has no duplicates.
I have another list P something like this
P = [ [1],[1,2],[2,3] [3,4], [3,5,7], [3,5,8] ...]
P is constant with size 1000.
P has no duplicates and within P, each element is sorted in ascending order.
What would be an efficient way to find the combinations from V existing in P.
For example
When V = [2,3,5,7,9,12]
combination of interest would be [[2,3],[3,5,7]]
.
I have already tried generating all possible arrangements from V and then filter by P. This is not very efficient. Just wondering if there is a better way to do what I asked for.
Since I already know P is any form of Tree a better option for this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在实践中,使用
set.issuperset
可能是最快的方法:也可以使用两个指针,沿每个列表逐渐前进。在Python中可能会较慢,但在C/C ++中更快:
Using
set.issuperset
is probably the fastest method in practice:It is also possible to use two pointers, gradually advancing along each list. It will probably be slower in Python, but faster in C/C++: