155.最小棧

設計一個支持 push,pop,top 操作,並能在常數時間內檢索到最小元素的棧。 push(x) – 將元素 x 推入棧中。 pop() – 刪除棧頂的元素。 top() – 獲取棧頂元素。 getMin() – 檢索棧中的最小元素。 class MinStack: def __init__(self): """ initialize your data structu
相關文章
相關標籤/搜索