题解 | #包含min函数的栈#
包含min函数的栈
http://www.nowcoder.com/practice/4c776177d2c04c2494f2555c9fcc1e49
# -*- coding:utf-8 -*-
class Solution:
    def __init__(self):
        self.__List = []
    def push(self, node):
        # write code here
        self.__List.append(node)
    def pop(self):
        # write code here
        return self.__List.pop()
    def top(self):
        # write code here
        return self.__List[-1]
    def min(self):
        # write code here
        return min(self.__List)
借助list 来实现了 stack 的操作
question:可以用 python min(list) 直接来实现min 的功能吗?


 查看3道真题和解析
查看3道真题和解析