[20251014] PGM / Lv2 / 짝지어 제거하기 / 이강현 #1116
Merged
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/12973?language=java
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
알파벳 소문자들로 이루어진 문자열에서 같은 문자 2개가 동시에 나타나면 제거한다.
이를 반복진행했을때, 문자열이 사라지면 1, 그렇지 않으면 0을 출력.
🔍 풀이 방법
스택
스택이 비어있거나 peek와 같지 않다면 넣고 아니라면 뺀다.
⏳ 회고
정말 쉬운 문제인데, 문자열을 두개씩 처리하고 같은지 체크하고 다시 문자열만들고 이러다가 시간초과가 났다.
큐나 스택을 쓰는 알고리즘이라는게 바로 떠오르지 않아서 팰린드롬인가? 이런 생각까지 했는데, 어이가 없다.