[20251017] PGM / LV2 / 두 큐 합 같게 만들기 / 강신지#1152
Merged
ShinHeeEul merged 1 commit intomainfrom Oct 17, 2025
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.
🧷 문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/118667
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
두 큐가 있음. 한 번에 한 큐의 맨 앞 원소를 꺼내 다른 큐 뒤에 붙일 수 있음. 두 큐의 합을 같게 만드는 최소 연산횟수 구하기. 불가능하면 -1.
🔍 풀이 방법
두 큐를 이어붙여 하나의 배열 생성 후 각 큐의 시작 인덱스를 이동시키며 계산
q1 내 값의 합이 원하는 값(모든 값을 더한 것의 절반)이 되도록 적절히 이동
⏳ 회고
뭔가 무지성으로 큐에서 옮기면서 풀면 시간초과가 날 것 같아서 힌트를 봄.
두 큐를 이어 붙여 투포인터로 푸는 방법은 생각하지 못했는데 좋은 방법인 것 같음.
근데 다시 직접 옮기는 방식으로 풀어보니 시간초과 나지 않는다...