Class MinStack definition?

We don’t get to define class Minstack and not even see it?

You need to build your own. So the provided functions are just the externally visible API. You implementation is responsible for the memory management of the stack. Thus you can use whatever language provided memory constructs to either operate like a stack / implement a stack where the query for the minimum element is going to be constant.

In Java you can follow this :

  • Your Solution class object will be instantiated and called as such:
  • Solution obj = new Solution();
  • obj.push(x);
  • obj.pop();
  • int top_Is =;
  • int min_Is = obj.getMin();

For the better understanding of problem statement follow this:
LeetCode Min Stack Problem

Click here to start solving coding interview questions