Untitled
raw download clone
TEXT
views 28
,
size 415 b
s1, s2 = [], []
for _ in range(q):
    ops = input().strip().split()
    # only push will have 2 values
    if len(ops) == 2:
        s1.append(ops[1])
    else:
        # is the queue empty?
        if len(s2) == 0:
            # reload it from the stack
            while s1:
                s2.append(s1.pop())
        if ops[0] == '2':
            s2.pop()
        else:
            print(s2[-1])
close fullscreen
Login or Register to edit or fork this paste. It's free.