题解 | #包含min函数的栈#
包含min函数的栈
https://www.nowcoder.com/practice/4c776177d2c04c2494f2555c9fcc1e49
# -*- coding:utf-8 -*- class Solution: def __init__(self): self.stack = [] self.min_stk = [] def push(self, node): self.stack.append(node) self.min_stk.append(node) def pop(self): self.stack.pop() self.min_stk.pop() def top(self): res = self.stack.pop() self.stack.append(res) return res def min(self): l = self.stack.copy() l.sort() return l[0]#我的实习求职记录#