[20251023] PGM/ Lv2 / 두 큐 합 같게 하기 / 이종환#1210
Merged
ShinHeeEul merged 1 commit intomainfrom Oct 23, 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
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
길이가 같은 두 개의 큐를 나타내는 정수 배열 queue1, queue2가 매개변수로 주어집니다. 각 큐의 원소 합을 같게 만들기 위해 필요한 작업의 최소 횟수를 return 하도록 solution 함수를 완성해주세요. 단, 어떤 방법으로도 각 큐의 원소 합을 같게 만들 수 없는 경우, -1을 return 해주세요.
🔍 풀이 방법
두 큐를 합친 arr를 만든 후, 투포인터를 통해 문제를 풀었다. 맨 처음에는 찾으면 바로 반환했는데, 지금 로직 상 나중에 찾는게 더 카운트가 적을 수도 있기에, 매번 찾을때마다 카운팅 후, 최솟값을 반환하는 식으로 변환하였다.
⏳ 회고