Sat May 13 2023 07:52:47 GMT+0000 (Coordinated Universal Time)
Saved by @Souvikdas
def unk(push,popp): j=0 stack=[] for i in push: stack.append(i) while stack and stack [-1]==popp[j]and len(popp)>j: stack.pop() j+=1 return not stack pushed = [1,2,3,4,5]; popped = [4,3,5,1,2] print(unk(pushed,popped))
Copy this HTML code:
Preview:
open_in_newInstructions on embedding in Medium
Comments