스택
-
[알고리즘] 10828 파이썬TodayILearned/알고리즘 2021. 3. 18. 20:05
# 스택의 queue, pop 등의 기능을 잘 익히도록 도와주는 문제였다. # if, elif, else문으로 잘 분기해줘야 에러가 발생하지 않아서 디버깅의 도움을 많이 받았다. 코드 # 21.03.16 # 백준 10828 번 풀이 # if ~ in 을 command[0] == 해당값 으로 수정하면 좀 더 깔끔한 코드가 나올 것 import sys case = int(input()) stack = [] for i in range(case): command = list(sys.stdin.readline().split()) if "push" in command: stack.append(command[1]) elif "pop" in command: if stack: print(stack.pop()) else:..