[20250311] BOJ / G2 / 후위 표기식 / 설진영 #228
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/1918
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
중위표기식을 후위표기식으로 바꾸기
🔍 풀이 방법
중위표기식을 후위표기식으로 바꾸는 방법은 문제에서 친절히 알려준다.
연산자를 괄호에 맞게 뒤로 넘겨주면 되는 문제라 우선순위에 맞게 스택을 사용해서 잘 출력해주면 된다.
마지막에는 스택에 남은 모든 연산자를 꺼내서 그대로 출력.
⏳ 회고
처음에는 연산자 우선순위에 따라 예시와 같이 모두 괄호를 쳐서 구현할까 하다가, 구현중에 연산자 우선순위를 잘 따지면
(기존 소괄호 고려) 될 것 같아 바로 구현했음. 일반화 하지 않고 구현하려니 많이 햇갈려서 실수한 것 같다.
@suyeun84 님 코드 보고 priority 알려주는 메서드 만들어 간단히 해결할 수 있었음ㅎ