This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Comparator; | |
import java.util.PriorityQueue; | |
class RunningMedianHeaps{ | |
PriorityQueue<Integer> minHeap = new PriorityQueue<Integer>(); | |
PriorityQueue<Integer> maxHeap = new PriorityQueue<Integer>(Comparator.reverseOrder()); | |
public double getMedian() { | |
int size = minHeap.size() + maxHeap.size(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This class is used to provide following utilities in primitive array | |
1- swap elements | |
2- reverse array between startIndex and endIndex | |
3- leftRotate array by a shift | |
*/ | |
class ArrayUtil | |
{ | |
public static final boolean checkIndexOutOfRange(int[] array, int index) | |
{ |
NewerOlder