JAVA-----------Easy Version To Understand!!!!!
\tPriorityQueue<Integer> minHeap = new PriorityQueue<>();//heap is a minimal heap by default\n\tPriorityQueue<Integer> maxHeap = new PriorityQueue<>(Collections
    \tPriorityQueue<Integer> minHeap = new PriorityQueue<>();//heap is a minimal heap by default\n\tPriorityQueue<Integer> maxHeap = new PriorityQueue<>(Collections.reverseOrder());//change to a maximum heap\n\n\t// Adds a number into the data structure.\n\tpublic void addNum(int num) {\n\t\tmaxHeap.offer(num);\n\t\tminHeap.offer(maxHeap.poll());\n\t\tif (maxHeap.size() < minHeap.size())\n\t\t\tmaxHeap.offer(minHeap.poll());\n\t}\n\n\t// Returns the median of current data stream\n\tpublic double findMedian() {\n\t\tif (maxHeap.size() == minHeap.size())\n\t\t\treturn (maxHeap.peek() + minHeap.peek()) / 2.0;\n\t\telse\n\t\t\treturn maxHeap.peek();\n\t}
[]