Code example for Stack

Methods: isEmpty, peek, pop

0
 
    @Override 
    public int pop() { 
        int poppedValue = stack.pop();
        if(poppedValue == min()) {
            minValueStack.pop();
        } 
        return poppedValue;
    } 
 
    @Override 
    public int min() { 
        if(minValueStack.isEmpty()) {
            return Integer.MAX_VALUE;
        } 
        else { 
            return minValueStack.peek();
        } 
    } 
}