标签:sub 最小 时间 pre esc 元素 col 包含min函数的栈 结构
# -*- coding:utf-8 -*- class Solution: def __init__(self): self.stack = [] self.minstack = [] def push(self, node): # write code here if not self.minstack or self.minstack[-1] >= node: self.minstack.append(node) self.stack.append(node) def pop(self): # write code here if self.stack[-1] == self.minstack[-1]: self.minstack.pop() self.stack.pop() def top(self): # write code here return self.stack[-1] def min(self): # write code here return self.minstack[-1]
标签:sub 最小 时间 pre esc 元素 col 包含min函数的栈 结构
原文地址:https://www.cnblogs.com/ansang/p/11993965.html