27. Get Min from Stack
Problem Description
Examples
Example 1
q = 7
queries = [[1, 2], [1, 3], [3], [2], [4], [1, 1], [4]][3, 2, 1]push(2) -> Stack: [2]
push(3) -> Stack: [2, 3]
peek() -> 3
pop() -> Stack: [2]
getMin() -> 2
push(1) -> Stack: [2, 1]
getMin() -> 1Example 2
Constraints
My Approach
Using Two Stacks (O(1) Time, O(N) Space)
Time and Auxiliary Space Complexity
Code (C++)
Code (Java)
Code (Python)
Contribution and Support
📍Visitor Count
Last updated