由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 算法面试题
相关主题
问个面试题求一下这题解法。
面试题哪里有讲k-way merge的?
请教一个常见的面试题的答案请教一下external sorting的问题
一个小公司面经刷题刷到没自信了
问一道题目。。2D median problem
一个特别的inplace merge two sorted arraysGoogle的一道面试题
[算法] unsorted array请教suffix array的问题
re: 面试归来,上面经回馈各位战友分享2个电面题目
相关话题的讨论汇总
话题: max话题: another话题: minimized话题: indexes话题: arrays
进入JobHunting版参与讨论
1 (共1页)
s*******e
发帖数: 4188
1
saw this on careercup:
3 sorted arrays, A, B, C, find indexes i, j, k, so that max(a-b, b-c, c-a)
is minimized. (a = A[i], b = B[j], c = C[k])
Another version is to minimize max(|a-b|, |b-c|, |c-a|).
d*******d
发帖数: 2050
2
我直接反映是对每个A的元素,在b里面bsearch,search到一个或两个,再在c里search,
再笨办法比,留最好的.
mlogn,m is the shortest of abc.

【在 s*******e 的大作中提到】
: saw this on careercup:
: 3 sorted arrays, A, B, C, find indexes i, j, k, so that max(a-b, b-c, c-a)
: is minimized. (a = A[i], b = B[j], c = C[k])
: Another version is to minimize max(|a-b|, |b-c|, |c-a|).

d*******d
发帖数: 2050
3
我的第二反应是,有没有可能用类似merge array的算法.

【在 s*******e 的大作中提到】
: saw this on careercup:
: 3 sorted arrays, A, B, C, find indexes i, j, k, so that max(a-b, b-c, c-a)
: is minimized. (a = A[i], b = B[j], c = C[k])
: Another version is to minimize max(|a-b|, |b-c|, |c-a|).

d*******d
发帖数: 2050
4
yeah,就是这个,merge 3 array那样走一边,update current correspond head of ABC,
after each update, recalculate the target value, keep the best one.
O(n);
code写好看了不容易.

【在 d*******d 的大作中提到】
: 我的第二反应是,有没有可能用类似merge array的算法.
C***U
发帖数: 2406
5
O(n)能实现
三个array集中到一个array

【在 s*******e 的大作中提到】
: saw this on careercup:
: 3 sorted arrays, A, B, C, find indexes i, j, k, so that max(a-b, b-c, c-a)
: is minimized. (a = A[i], b = B[j], c = C[k])
: Another version is to minimize max(|a-b|, |b-c|, |c-a|).

S******1
发帖数: 269
6
思路和那个找出包括所有keywords最短的subString一样吧。
a********m
发帖数: 15480
7
纯merge不行吧。还要保证abc在三个数组中。
1 (共1页)
进入JobHunting版参与讨论
相关主题
分享2个电面题目问一道题目。。
minimize the max of sums of each segment in an array一个特别的inplace merge two sorted arrays
amazon tel interview[算法] unsorted array
请教一道题re: 面试归来,上面经回馈各位战友
问个面试题求一下这题解法。
面试题哪里有讲k-way merge的?
请教一个常见的面试题的答案请教一下external sorting的问题
一个小公司面经刷题刷到没自信了
相关话题的讨论汇总
话题: max话题: another话题: minimized话题: indexes话题: arrays