两个已排序的数组的交集数组、两个

2023-09-11 22:36:26 作者:予忆

由于两个排序数组: A B 。数组的大小 A 和数组的大小 B 。如何找到的路口 A B

Given two sorted arrays: A and B. The size of array A is La and the size of array B is Lb. How to find the intersection of A and B?

如果大得多,那么会有的交集任何区别寻找算法?

If La is much bigger than Lb, then will there be any difference for the intersection finding algorithm?

推荐答案

使用 set_intersection 为此处。通常的实现将工作类似于归并排序算法合并的部分。

Use set_intersection as here. The usual implementation would work similar to the merge part of merge-sort algorithm.