1class Solution:2def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:3stack = []4i = 05for num in pushed:6stack.append(num) # we are pushing the number to the stack7while len(stack) > 0 and stack[len(stack) - 1] == popped[i]:8# if the last element of the stack is equal to the popped element9stack.pop()10i += 1 # we are incrementing i11return True if len(stack) == 0 else False