[20251013] BOJ / G5 / 괄호의 값 / 설진영 #1110
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://www.acmicpc.net/problem/2504
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
괄호열의 값을 계산하는 문제 () = 2, [] = 3이고, (X) = 2×X, [X] = 3×X로 계산함. 연속된 괄호는 덧셈, 올바르지 않은 괄호열은 0 출력
🔍 풀이 방법
ArrayDeque로 괄호 검증하면서 동시에 값 계산
여는 괄호 만나면 temp에 곱셈, 닫는 괄호 만나면 직전이 여는 괄호인 경우에만 temp를 result에 누적하고 temp를 나눔
스택으로 괄호 쌍 검증
⏳ 회고
스택 + 곱셈 누적 방식으로 풀이함 ez