We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Enter your code here. Read input from STDIN. Print output to STDOUTinstructions=int(input())ops=[]for_inrange(instructions):ops.append(list(input().split()))s=""undo=[]foropinops:ifop[0]=='1':undo.append(s)s+=op[1]elifop[0]=='2':undo.append(s)s=s[0:-int(op[1])]elifop[0]=='3':print(s[int(op[1])-1])elifop[0]=='4':s=undo.pop(-1)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Simple Text Editor
You are viewing a single comment's thread. Return to all comments →
Python