由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 请问一个老的google题
相关主题
[合集] 一道Google面试题a[i] + b[j] = c[k] 的题有靠谱的答案不?
算法一问details 2nd smallest element in an array
请教一个老算法题, k-th largest sum请教一道题目
算法问题,m*m matrixamazon 电面题
一个NxN矩阵每行每列都sort好,如何排序?amazon phone interview
find median for k sorted arrays两个Sorted Array,找K smallest element
[算法] unsorted array问道面试题
merge k个数组怎样的方法好?O(lgk)解法Find the k-th Smallest in Two Sorted Arrays
相关话题的讨论汇总
话题: arrays话题: smallest话题: pairs话题: results话题: given
进入JobHunting版参与讨论
1 (共1页)
v******a
发帖数: 54
1
Given two sorted arrays A, B, find the m pairs with the smallest sums.
For example: A={1, 2, 4, 5, 6}, B={3, 5, 7, 9}
m=3
Results(1, 3),(2, 3),(1, 5)
看了以前大家的讨论,
最好的complexity是多少?
貌似有一个DP的,怎么做?
I**A
发帖数: 2345
2
I think that one is different from this one though I don't remember what
that one is?
For this one, since we only need m pairs, we can select the first m elements
from both A and B (if less than m, then choose the whole array), name them
as A' and B'
The algorithm that I can think of is for each element in A', add it with
each of the elements of B', meanwhile, keep a edited max heap to maintain
the m smallest sum value (of course, we need to keep the element values as
well). Since the arrays are

【在 v******a 的大作中提到】
: Given two sorted arrays A, B, find the m pairs with the smallest sums.
: For example: A={1, 2, 4, 5, 6}, B={3, 5, 7, 9}
: m=3
: Results(1, 3),(2, 3),(1, 5)
: 看了以前大家的讨论,
: 最好的complexity是多少?
: 貌似有一个DP的,怎么做?

h**6
发帖数: 4160
3
这个题以前问过多次,帮楼主找到了链接:
http://www.mitbbs.com/article_t1/JobHunting/31611565_0_1.html
I**A
发帖数: 2345
4
简单描述一下你的算法如何?

【在 h**6 的大作中提到】
: 这个题以前问过多次,帮楼主找到了链接:
: http://www.mitbbs.com/article_t1/JobHunting/31611565_0_1.html

P********l
发帖数: 452
1 (共1页)
进入JobHunting版参与讨论
相关主题
O(lgk)解法Find the k-th Smallest in Two Sorted Arrays一个NxN矩阵每行每列都sort好,如何排序?
讨论做题:find kth smallest number in two sorted arrays atfind median for k sorted arrays
问题:Find the minimum number of "swaps" needed to sort an array[算法] unsorted array
Find the Kth smallest element in 2 sortedmerge k个数组怎样的方法好?
[合集] 一道Google面试题a[i] + b[j] = c[k] 的题有靠谱的答案不?
算法一问details 2nd smallest element in an array
请教一个老算法题, k-th largest sum请教一道题目
算法问题,m*m matrixamazon 电面题
相关话题的讨论汇总
话题: arrays话题: smallest话题: pairs话题: results话题: given