일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 잡생각
- 읽기
- 3줄정리
- leetcode
- 10분
- 매일
- 스탭퍼
- 운동
- 영어공부
- 링피트
- English
- 화상영어
- 월간
- Writing
- 사이드
- 미드시청
- 파비최
- 영어원서읽기
- 뭐든
- Daily Challenge
- 괜찮음
- 30분
- 리얼 클래스
- 쓰릴오브파이트
- realclass
- FIT XR
- 개발자
- Problem Solving
- 만화도
- 프로젝트
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/evaluate-reverse-polish-notation/
Evaluate Reverse Polish Notation - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
스택을 이용하는거 까진 알겠는데
생각보다 간단했다는건 몰랐음 =_=;
class Solution:
def evalRPN(self, tokens: List[str]) -> int:
st = []
for token in tokens:
if token in ['*', '/', '-', '+']:
r = st.pop()
l = st.pop()
st.append(str(int(eval(l+token+r))))
else:
st.append(token)
return int(st[-1])
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
Today's Challenge (0) | 2022.12.19 |
---|---|
Today's Challenge (0) | 2022.12.18 |
Today's Challenge (0) | 2022.12.16 |
Today's Challenge (0) | 2022.12.15 |
Today's Challenge (0) | 2022.12.14 |
Comments