Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
이중 우선순위 큐
🧭 풀이 시간
45분
👀 체감 난이도
✏️ 문제 설명
이중 우선순위 큐에 값을 넣음
뺄 때
1이면 최대값 빼고-1이면 최소값 빼기🔍 풀이 방법
최소힙, 최대힙 두 개 쓰는 문제..
접근법은 5분만에 나왔는데 시간초과 해결하느라 좀 걸림
맵에는 해당 숫자가 큐에 얼마나 있는지 저장함
delete할 때 맵의 값이0이면 다른 힙에서 삭제한 값이라 넘어가고0이 아니라면 삭제가 안 된 값이니까 맵 값을 수정.만약
1 -> 0인 경우 비교하기 편하라고 그냥 해당 값을 맵에서 아예 삭제넣을 때는 힙이랑 맵에 둘 다 넣어주면 됨.
맵이 비었으면
EMPTY출력, 아니면 맵의 값이 0이 아닌 가장 처음 나오는 힙의 값 출력..⏳ 회고
힙은 대체로 난이도에 비해 어려운듯
그러고보니 트리맵도 정렬되네.. 훨씬 쉽겠는데