Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stack] bj 17608 막대기 / bj 1935 후위표기식2 #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

loveitall
Copy link
Collaborator

📒 문제번호 : bj 17608 막대기, bj 1935 후위표기식2

[bj17608] 막대기
image

[bj1935] 후위표기식2
image

☑️ PR Point

어려웠습니다... (후위표기식 ㅎㅎㅎ)
둘 다 stack을 사용해서 풀었고, 1935번의 경우 소수점 2자리 출력 관련해서 새롭게 배울 수 있었습니다! op1, op2 사칙연산 계산이 은근 헷갈려서 삽질했습니다 ㅎㅎ stack배열에 알파벳 값을 int 형태로 넣는 것도 생각하는데 시간이 오래걸렸습니다..이런 문제 많이 풀어봐야할 거 같아요!

  • PR Point 1
  • PR Point 2

⏱️시간복잡도

17608 : O(N)
1935 : O(N)

@loveitall loveitall requested a review from a team as a code owner February 6, 2023 14:06
@loveitall loveitall requested review from skylartosf, wkdyujin and IslandofDream and removed request for a team February 6, 2023 14:06
Copy link

@skylartosf skylartosf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

너무 잘했어요 ❤️

Copy link
Member

@IslandofDream IslandofDream left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생했습니다!

Comment on lines +19 to +20
op2 = stack.pop()
op1 = stack.pop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

미리 변수에 받아주니까 좋네요

Comment on lines +12 to +15
for i in postfix :
if 'A' <= i <= 'Z' :
# 후위표기식의 값이 알파벳이면, 스택에 값을 넣어준다. str -> int 형태로
stack.append(num[ord(i) - ord('A')])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link

@wkdyujin wkdyujin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

배워가요..~ 나는 다시 풀어야겠어

Comment on lines +9 to +13
for i in range(1, n) :
last = stack.pop()
if last > before :
count += 1
before = last

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

내가 스택을 어렵게 사용했네...
코드 깔끔하고 너무 좋아요

Comment on lines +13 to +14
if 'A' <= i <= 'Z' :
# 후위표기식의 값이 알파벳이면, 스택에 값을 넣어준다. str -> int 형태로

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

알파벳 여부를 기준으로 판별했구나 이렇게 하면 바로 계산이 가능하네 코드 너무 깔끔해 좋다...

@loveitall loveitall self-assigned this Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants