最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

两个已排序数组的交集

SEO心得admin29浏览0评论
本文介绍了两个已排序数组的交集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

给定两个已排序的数组:A 和 B.数组A的大小为La,数组B的大小为Lb.如何找到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?

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

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.

发布评论

评论列表(0)

  1. 暂无评论