parenthesis1 [자료구조] 스택 파이썬(LeetCode, Programmers) class ArrayStack: def __init__(self): self.data = [] def size(self): return len(self.data) def isEmpty(self): return self.size() == 0 def push(self, item): self.data.append(item) def pop(self): return self.data.pop() def peek(self): return self.data[-1] def solution(expr): match = { ')': '(', '}': '{', ']': '[' } S = ArrayStack() for c in expr: if c in '({[': S.push(c) elif c in match: if S.size.. 2021. 4. 20. 이전 1 다음