Notice
Recent Posts
Recent Comments
Link
목록우선순위큐 (1)
study record
[프로그래머스-자바] 힙 Heap
더 맵게 PriorityQueue 를 사용하는 문제 heap은 정렬하지 않아도 peek()이나 poll()하면 가장 작은 값이 나온다. 힙은 우선순위 큐를 위해 만들어진 자료구조로, 부모노드 키 값이 자식 노드 키 값보다 항상 크거나 작다. import java.util.PriorityQueue; public class Spicer { public int solution(int[] scoville, int K) { int answer = 0; PriorityQueue heap = new PriorityQueue(); for (int i = 0; i K) { if(heap.siz..
알고리즘
2021. 5. 4. 10:52