@@ -0,0 +1,1430 @@
+// 155. Min Stack%0A/**%0A * Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.%0A * %0A * push(x) -- Push element x onto stack.%0A * pop() -- Removes the element on top of the stack.%0A * top() -- Get the top element.%0A * getMin() -- Retrieve the minimum element in the stack.%0A *%0A * Example:%0A *%0A * MinStack minStack = new MinStack();%0A * minStack.push(-2);%0A * minStack.push(0);%0A * minStack.push(-3);%0A * minStack.getMin();   --%3E Returns -3.%0A * minStack.pop();%0A * minStack.top();      --%3E Returns 0.%0A * minStack.getMin();   --%3E Returns -2.%0A * %0A * Tags: Stack Design%0A *%0A * Similar Problems: (H) Sliding Window Maximum%0A *%0A * Author: Xinyue Zhang%0A */%0A%0Apublic class MinStack %7B%0A    %0A    private Stack%3CInteger%3E s1 = new Stack%3CInteger%3E();%0A    private Stack%3CInteger%3E s2 = new Stack%3CInteger%3E();%0A%0A    /** initialize your data structure here. */%0A    public MinStack() %7B%0A        %0A    %7D%0A    %0A    public void push(int x) %7B%0A        if (s2.empty() %7C%7C x %3C= getMin()) s2.push(x);%0A        s1.push(x);%0A        %0A    %7D%0A    %0A    public void pop() %7B%0A        if (s1.pop() == getMin()) s2.pop();%0A    %7D%0A    %0A    public int top() %7B%0A        return s1.peek();%0A    %7D%0A    %0A    public int getMin() %7B%0A        return s2.peek();%0A    %7D%0A%7D%0A%0A/**%0A * Your MinStack object will be instantiated and called as such:%0A * MinStack obj = new MinStack();%0A * obj.push(x);%0A * obj.pop();%0A * int param_3 = obj.top();%0A * int param_4 = obj.getMin();%0A */%0A

Create 155_Min_Stack.java