-
Notifications
You must be signed in to change notification settings - Fork 0
LeetCode 295: Find Median from Data Stream #62
Copy link
Copy link
Open
Labels
blind-75Blind 75 - Blind-75 problemsBlind 75 - Blind-75 problemsheapBlind 75 - Heap problemsBlind 75 - Heap problems
Description
LeetCode 295: Find Median from Data Stream
Category: Heap
Difficulty: See LeetCode
Solution File: src/heap/find_median_from_data_stream.py
Test File: tests/test_find_median_from_data_stream.py
Problem Description
The median is the middle value in an ordered integer list. If the size of the list is even,
there is no middle value, and the median is the mean of the two middle values.
Implement the MedianFinder class:
- MedianFinder() initializes the MedianFinder object.
- void addNum(int num) adds the integer num from the data stream to the data structure.
- double findMedian() returns the median of all elements so far.
Example 1:
Input: ["MedianFinder", "addNum", "addNum", "findMedian", "addNum", "findMedian"]
[[], [1], [2], [], [3], []]
Output: [null, null, null, 1.5, null, 2.0]
Constraints:
- -10^5 <= num <= 10^5
- There will be at least one element in the data structure before calling findMedian.
Tasks
- Implement the solution in
src/heap/find_median_from_data_stream.py - Ensure all test cases pass
- Analyze time complexity
- Analyze space complexity
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
blind-75Blind 75 - Blind-75 problemsBlind 75 - Blind-75 problemsheapBlind 75 - Heap problemsBlind 75 - Heap problems