Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- NLP
- PytorchLightning
- Matplotlib
- datascience
- GCP
- wandb
- leetcode
- rnn
- pep8
- FDS
- pytorch
- Kubernetes
- FastAPI
- 프로그래머스
- 알고리즘
- 백준
- GIT
- Kaggle
- vscode
- 네이버AItech
- torchserve
- NaverAItech
- DeepLearning
- python
- docker
- github
- GitHub Action
- autoencoder
- 완전탐색
- 코딩테스트
Archives
- Today
- Total
Sangmun
python 으로 stack 직접 구현하기 본문
스택 대표 문제
https://www.acmicpc.net/problem/4949
while True :
a = input()
stack = []
if a == "." :
break
for i in a :
if i == '[' or i == '(' :
stack.append(i)
elif i == ']' :
if len(stack) != 0 and stack[-1] == '[' :
stack.pop() # 맞으면 지워서 stack을 비워줌 0 = yes
else :
stack.append(']')
break
elif i == ')' :
if len(stack) != 0 and stack[-1] == '(' :
stack.pop()
else :
stack.append(')')
break
if len(stack) == 0 :
print('yes')
else :
print('no')
'알고리즘 > 알고리즘(초급)' 카테고리의 다른 글
배낭 문제(냅색 문제) - 1 (분할가능한 배낭 문제) (0) | 2022.12.20 |
---|---|
python queue 구현 (0) | 2022.12.04 |
투포인터 (0) | 2022.11.23 |
백트래킹을 이용한 부분 집합을 구하는 알고리즘 (0) | 2022.11.21 |
유클리드 호제법(최대공약수), 최소공배수 (0) | 2022.11.18 |
Comments