class Solution:
def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:
popped = deque(popped)
stk = []
for e in pushed:
stk.append(e)
while stk and stk[-1] == popped[0]:
stk.pop()
popped.popleft()
return not stk
O(N)
(N: pushed
길이)