1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 19:18:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/栈的最小值 [min-stack-lcci].html

1 line
485 B
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<p>请设计一个栈除了常规栈支持的pop与push函数以外还支持min函数该函数返回栈元素中的最小值。执行push、pop和min操作的时间复杂度必须为O(1)。</p><br><p><strong>示例:</strong><pre>MinStack minStack = new MinStack();<br>minStack.push(-2);<br>minStack.push(0);<br>minStack.push(-3);<br>minStack.getMin(); --> 返回 -3.<br>minStack.pop();<br>minStack.top(); --> 返回 0.<br>minStack.getMin(); --> 返回 -2.</pre></p>