Last active
April 26, 2023 10:32
-
-
Save modos/f8a549bd44a8e34c9e5096fc05b3dd18 to your computer and use it in GitHub Desktop.
هیستوری
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
q = int(input()) | |
S = [] | |
stack = [[]] | |
for i in range(q): | |
A = list(input().split(" ")) | |
if A[0] == "insert": | |
p = int(A[1]) | |
p -= 1 | |
SP = S.copy(); | |
SP.insert(p, A[2]) | |
stack.append(SP) | |
elif A[0] == "delete": | |
p = int(A[1]) | |
p -= 1 | |
SP = S.copy() | |
SP.pop(p) | |
stack.append(SP) | |
else: | |
stack.pop() | |
S = stack[len(stack) - 1] | |
#a, ab, cab, cb, | |
for ch in S: | |
print(ch, end="") | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment