Skip to content

Commit 4c94ea3

Browse files
committed
Added Missing Description for Find Median from Data Stream
1 parent c61cde6 commit 4c94ea3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/find_median_from_data_stream.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
use std::{collections::BinaryHeap, cmp::Reverse};
22

3+
/// The median is the middle value in an ordered integer list. If the size of
4+
/// the list is even, there is no middle value, and the median is the mean of
5+
/// the two middle values.
6+
///
7+
/// * For example, for `arr = [2,3,4]`, the median is `3`.
8+
///
9+
/// * For example, for `arr = [2,3]`, the median is `(2 + 3) / 2 = 2.5`.
10+
///
11+
/// Implement the MedianFinder class:
12+
///
13+
/// * `MedianFinder()` initializes the `MedianFinder` object.
14+
///
15+
/// * `void addNum(int num)` adds the integer `num` from the data stream to the
16+
/// data structure.
17+
///
18+
/// * `double findMedian()` returns the median of all elements so far. Answers
19+
/// within `10^-5` of the actual answer will be accepted.
320
struct MedianFinder {
421
min_heap: BinaryHeap<Reverse<i32>>,
522
max_heap: BinaryHeap<i32>

0 commit comments

Comments
 (0)