-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
stack = [] | ||
tmp_ans = 1 # 곱하기 연산을 해야하므로 1부터 시작 | ||
|
||
def filter_correct(text): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 예외처리를 정리하셔서 이렇게 filter로 걸어주시는게 너무 좋은 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시 (8) 이렇게 들어오는 케이스도 필터링이 되나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스택을 검증해주는 메소드 하나 덕분에 코드가 전반적으로 깔끔한 것 같습니다. 주석도 이해하기 쉽게 작성해주셨고, 이해하기 쉬웠던 풀이였습니다. 수고하셨습니다.
stack = [] | ||
tmp_ans = 1 # 곱하기 연산을 해야하므로 1부터 시작 | ||
|
||
def filter_correct(text): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스택의 유효성을 검증해주는 함수를 따로 정의하신 것 굉장히 좋은 것 같습니다.
다만 cond2에서 count는 O(N)이 소요되는 연산이므로, 모든 스택 연산이 끝났을 때 스택 리스트에 원소가 남아있다면 애초에 개수가 안맞았던 것 아니었을까? 로 접근해보면 어떨까 싶습니다!
tmp_ans = 1 # 곱하기 연산을 해야하므로 1부터 시작 | ||
|
||
def filter_correct(text): | ||
cond1 = (text.count('(')==text.count(')')) & (text.count('[')==text.count(']')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
예외처리도 스터디 때 말씀 드렸던 것처럼 count의 시간복잡도는 O(n)
참고 링크: https://stackoverflow.com/questions/44812468/what-is-the-time-complexity-of-python-lists-count-function
PR Summary
풀이시간
접근법
회고
ISSUE NUMBER