由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Groupon 電面
相关主题
find medium number in stream 这题怎么作请教一道题目
再问一道题find the median of an infinite data stream of integers
[算法] unsorted arrayHow to find median of a stream of integers ?
上一题看看Google电话面试题目
一个小公司面经[合集] Google电话面试题目
问一道老题Search in a sorted, rotated list
征解几道large scale的数字题问道面试题
一道算法题的follow up,求解问个关于排序的面试题
相关话题的讨论汇总
话题: median话题: stream话题: given话题: sorted话题: element
进入JobHunting版参与讨论
1 (共1页)
c******5
发帖数: 84
1
Median of Integer Stream
Given a stream of unsorted integers, find the median element in sorted
order at any given time.
So, we will be receiving a continuous stream of numbers in some random
order and we don’t know the stream length in advance.
Write a function that finds the median of the already received numbers
efficiently at any time. We will be asked to find the median multiple times.
Just to recall, median is the middle element in an odd length sorted array,
and in the even case it’s the average of the middle elements.
t**v
发帖数: 101
2
what is their answer ? I can only think of hash table. O(n)

times.
array,

【在 c******5 的大作中提到】
: Median of Integer Stream
: Given a stream of unsorted integers, find the median element in sorted
: order at any given time.
: So, we will be receiving a continuous stream of numbers in some random
: order and we don’t know the stream length in advance.
: Write a function that finds the median of the already received numbers
: efficiently at any time. We will be asked to find the median multiple times.
: Just to recall, median is the middle element in an odd length sorted array,
: and in the even case it’s the average of the middle elements.

c******5
发帖数: 84
3
I think their answer should be maintain a max-heap which stores the lower
half values and a min-heap which stores the upper half values. Here are the
details for this solution:
http://www.ardendertat.com/2011/11/03/programming-interview-que

【在 t**v 的大作中提到】
: what is their answer ? I can only think of hash table. O(n)
:
: times.
: array,

1 (共1页)
进入JobHunting版参与讨论
相关主题
问个关于排序的面试题一个小公司面经
a problem from leetcode: high efficiency algorithm for combinations problem问一道老题
G题一道(1)征解几道large scale的数字题
请教个面试题一道算法题的follow up,求解
find medium number in stream 这题怎么作请教一道题目
再问一道题find the median of an infinite data stream of integers
[算法] unsorted arrayHow to find median of a stream of integers ?
上一题看看Google电话面试题目
相关话题的讨论汇总
话题: median话题: stream话题: given话题: sorted话题: element