Priority Queue
- 힙 구조를 이용해서 만드는데 큰 값이 맨 앞으로 가는 최대 힙, 최소 힙이 있다.
PriorityQueue<Integer> minHeap = new PriorityQueue<>();
PriorityQueue<Integer> maxHeap = new PriorityQueue<>(Collections.reverseOrder());
//이중 배열에서 0번째 낮은 숫자가 우선순위가 높은 방식 _ 오름차순 (람다식)
PriorityQueue<int[]> pq = new PriorityQueue<>((o1, o2) -> o1[0] - o2[0]);
//이중 배열에서 0번째 낮은 숫자가 우선순위가 높은 방식 _ 오름차순 (Comparator)
PriorityQueue<int[]> pq = new PriorityQueue<>(new Comparator<int[]>() {
@Override
public int compare(int[] o1, int[] o2) {
return o1[0] - o2[0];
};
});