两个已排序的数组的交集 [英] The intersection of two sorted arrays

查看:96
本文介绍了两个已排序的数组的交集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于两个排序数组: 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.

这篇关于两个已排序的数组的交集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆