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.
문제
풀이 후기
큐를 이용해야 하는 문제였는데, 엉뚱하게 스택으로 풀려고 하다가 삽질했다.
문제의 '먼저 배포되어야 하는 순서대로' 이런 부분에서 FIFO라는 것을 캐치했어야 했다.
큐로 풀어야 한다는 것을 깨닫고 나서는 꽤 수월하게 풀었는데, 더 좋은 코드가 있을지 궁금하다.
다른 사람의 풀이와 비교
큐를 이용한 풀이 방식은 어쩔 수 없이 O(n^2)인데, 큐를 이용하지 않고 O(n)으로 푼 풀이가 좋아요 1등이길래 가져와봤다.
그 외는 다 큐를 이용한 듯하며, 이 풀이 방식 중에서는 내 코드가 제일 마음에 든다.
좋아요 1등 풀이