[20250311] BOJ / G2 / 후위 표기식 / 김수연 #222
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
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
중위 표기법으로 적혀있는 수식을 후위 표기법으로 바꾸기
🔍 풀이 방법
문자는 바로 출력하고, 연산자는 stack에 넣는다.
이후, stack의 연산자와 현재 연산자의 우선순위를 비교해서 현재 연산자보다 우선순위가 크거나 같은 연산자가 stack에 있으면 해당 값들을 다 출력한다.
⏳ 회고
stack을 사용한다는 거는 보자마자 알았는데, 연산자에 우선순위를 설정하는 거를 생각하지 못했다...