t**r 发帖数: 3428 | 1 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. - See more at: http://www.ardendertat.com/2011/11/03/programming-interview-questions-13-median-of-integer-stream/#sthash.Bn5jexex.dpuf |
I*******g 发帖数: 7600 | 2 用两个priority_queue
order
numbers
Write
efficiently
【在 t**r 的大作中提到】 : 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. - See more at: http://www.ardendertat.com/2011/11/03/programming-interview-questions-13-median-of-integer-stream/#sthash.Bn5jexex.dpuf
|
s**x 发帖数: 7506 | 3 Cc150 上的题吧?先读一遍CC150,再刷leetcode. |
m******y 发帖数: 219 | 4 类似quick sort的思路,把数字一个一个放到sorted后的位置,如果index正好是
Median输出,否则根据大小左右移动。两个priority queue有点大材小用 |
m******3 发帖数: 346 | 5 quick sort不行吧,stream你不知道有多少元素阿。 |