Skip to main content
DevHives

Stack With Constant-Time Minimum

Loading editor…

3 examples run when you press Run. Submit checks every hidden test too.

Case 1
Input:
["MinStack","push","push","push","getMin","pop","getMin","top"], [[],[5],[8],[2],[],[],[],[]]
Expected:
[null,null,null,null,2,null,5,8]
Case 2
Input:
["MinStack","push","push","push","pop","getMin","pop","getMin"], [[],[3],[1],[1],[],[],[],[]]
Expected:
[null,null,null,null,null,1,null,3]
Case 3
Input:
["MinStack","push","top","getMin","pop","push","push","getMin","top"], [[],[-4],[],[],[],[0],[-1],[],[]]
Expected:
[null,null,-4,-4,null,null,null,-1,-1]
Ready

Run checks your code against the 3 examples. Submit checks it against all 73 tests and needs a free account. You can also try ideas in the free JavaScript or Python compiler.