234. Palindrome Linked List
- 描述:
栈的实现 - 思路:
通过列表进行实现 - 代码
class MinStack: def __init__(self): """ initialize your data structure here. """ self.data=[] def push(self, x): """ :type x: int :rtype: void """ self.data.append(x) def pop(self): """ :rtype: void """ self.data=self.data[:-1] def top(self): """ :rtype: int """ return self.data[-1] def getMin(self): """ :rtype: int """ return min(self.data) # Your MinStack object will be instantiated and called as such: # obj = MinStack() # obj.push(x) # obj.pop() # param_3 = obj.top() # param_4 = obj.getMin()