推荐:数据科学课程和书籍清单以及培训讲座


一亩三分地论坛

 找回密码
 获取更多干活,快来注册

一亩三分地官方iOS手机应用下载
查看: 1382|回复: 1
收起左侧

[数组] leetcode 350. Intersection of Two Arrays II Follow up

[复制链接] |试试Instant~ |关注本帖
111180611 发表于 2016-6-5 05:46:15 | 显示全部楼层 |阅读模式

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干活,快来注册

x
Given two arrays, write a function to compute their intersection.

Example:
Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].

Follow up:
What if elements of nums2 are stored on disk, and the memory is limited such that you cannot load all elements into the memory at once?

Anyone has idea about the follow up question?
handsomecool 发表于 2016-6-5 10:40:32 | 显示全部楼层
可以把nums1放进HashMap然后loop through nums2
如果nums1也太大就两个都external merge sort 再用2 pointers
回复 支持 反对

使用道具 举报

本版积分规则

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明

custom counter

GMT+8, 2017-8-22 15:49

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表