백준 / 10828 / 스택 / Stack
2023. 12. 18. 15:22
📚문제 📝풀이 # 10828 스택 (Silver IV) import sys stack = [] for _ in range(int(input())): order = sys.stdin.readline().rstrip().split() if order[0] == 'push': stack.append(order[1]) elif order[0] == 'top': print(stack[-1] if stack else -1) elif order[0] == 'pop': print(stack.pop() if stack else -1) elif order[0] == 'size': print(len(stack)) elif order[0] == 'empty': print(0 if stack else 1) 스택,큐,덱 문제 모..