목록Priority Queue (2)
N
https://leetcode.com/problems/furthest-building-you-can-reach/ Furthest Building You Can Reach - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 최소힙을 이용한 문제풀이. 벽돌과 사다리를 이용해 가장 멀리 갈 수 있는 빌딩의 인덱스를 리턴하면 된다. pq라는 이름으로 우선순위 큐(최소 힙)을 선언한다. for문으로 1부터 heights의 길이만큼 순회. 현재 빌딩의 높이 - 이전 빌딩의 ..
https://leetcode.com/problems/path-with-minimum-effort/ Path With Minimum Effort - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 우선순위큐로를 이용한 풀이. MinHeap으로 우선순위 큐를 구현. BFS 방식과 비슷하게 PriorityQueue에 방문할 좌표와 minimum effort를 넣으면 된다. pq에 push하면 알아서 minHeap으로 정렬해주기 때문에 방문할 좌표와 방문 여부를 확인해..