Skip to content

Instantly share code, notes, and snippets.

@modos
Last active April 26, 2023 10:32
Show Gist options
  • Save modos/f8a549bd44a8e34c9e5096fc05b3dd18 to your computer and use it in GitHub Desktop.
Save modos/f8a549bd44a8e34c9e5096fc05b3dd18 to your computer and use it in GitHub Desktop.
هیستوری
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