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.
defgetMax(operations):# Write your code herestack=list()sorted_stack=[]answer=[]foriinrange(len(operations)):query=list(map(int,operations[i].split()))ifquery[0]==1:stack.append(query[1])sorted_stack.append(query[1])sorted_stack.sort()elifquery[0]==2:sorted_stack.remove(stack.pop())else:answer.append(sorted_stack[-1])returnanswer
Maximum Element
You are viewing a single comment's thread. Return to all comments →