Back to Browse

DSA Problem 018: Minimum Stack

7 views
Dec 31, 2025
9:37

#dsa #javascript #datastructure #algorithm Solution: https://github.com/therajatg/DSA/blob/main/018-minimum-stack.js Minimum Stack: Design a stack class that supports the push, pop, top, and getMin operations. MinStack() initializes the stack object. void push(int val) pushes the element val onto the stack. void pop() removes the element on the top of the stack. int top() gets the top element of the stack. int getMin() retrieves the minimum element in the stack. Each function should run in O(1) time. Example MinStack minStack = new MinStack(); minStack.push(1); minStack.push(2); minStack.push(0); minStack.getMin(); // return 0 minStack.pop(); minStack.top(); // return 2 minStack.getMin(); // return 1

Download

0 formats

No download links available.

DSA Problem 018: Minimum Stack | NatokHD