Implement Min Heap and Max Heap
Learning DSA practice problem on Onlearn.
Difficulty: medium.
Topics: Min Heap and Max Heap Implementation, Priority Queue, Data Structures, Algorithm, Time Complexity, Space Complexity, Big O Notation, array representation, min-heap, heap, heap operations, max-heap, Heap (Priority Queue), Min-Heap, Max-Heap, Arrays, Heap Operations.
Median of a Data Stream Problem Statement Design a data structure that supports the following two operations: addNum(int num): Adds an integer num from the data stream into the data structure. findMedian(): Returns the median of all numbers added so far. The median is the middle value in an ordered integer list. If the size of the list is even, there is no single middle value, and the median is the average of the two middle values. Example: Constraints: 10^5 <= num <= 10^5 At most 5 10^4 calls will be made to addNum and findMedian. When findMedian is called, there will be at least one number in the data structure.