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

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

问题描述

给定两个已排序的数组:AB.数组A的大小为La,数组B的大小为Lb.如何找到AB的交集?

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?

如果LaLb大很多,那么求交算法会有什么不同吗?

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

推荐答案

Use set_intersection as 此处.通常的实现类似于归并排序算法的合并部分.

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

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

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