@@ -0,0 +1,1535 @@
+public class Problem3_2 %7B%0A  public static void main(String%5B%5D args) %7B%0A    Stack%3CInteger%3E stack = new Stack%3C%3E();%0A%0A    stack.push(1);%0A    stack.push(2);%0A    stack.push(3);%0A    stack.push(4);%0A    stack.push(5);%0A    stack.push(-1);%0A    stack.push(3);%0A    stack.push(4);%0A%0A    System.out.println(stack.min() + %22 should be -1%22);%0A%0A    System.out.println(stack.pop() + %22 should be 4%22);%0A    System.out.println(stack.pop() + %22 should be 3%22);%0A    System.out.println(stack.pop() + %22 should be -1%22);%0A%0A    System.out.println(stack.min() + %22 should be 1%22);%0A  %7D%0A%0A  static class Stack%3CT%3E %7B%0A    Node%3CT%3E head = null;%0A    // stack holding the lowest value in the stack%0A    Node%3CNode%3CT%3E%3E min = null;%0A%0A    public Stack() %7B%0A    %7D%0A%0A    public void push(T val) %7B%0A      if (head == null) %7B%0A        head = new Node%3C%3E(val);%0A        min = new Node%3C%3E(head);%0A      %7D else %7B%0A        Node%3CT%3E node = new Node%3C%3E(val);%0A        if (((Integer) val) %3C ((Integer) min.val.val)) %7B%0A          Node%3CNode%3CT%3E%3E nextMin = new Node%3C%3E(node);%0A          nextMin.next = min;%0A          min = nextMin;%0A        %7D%0A        node.next = head;%0A        head = node;%0A      %7D%0A    %7D%0A%0A    public T pop() %7B%0A      if (head == null) %7B%0A        throw new IllegalStateException(%22Stack is empty!%22);%0A      %7D%0A      if (min.val == head) %7B%0A        min = min.next;%0A      %7D%0A      T ret = head.val;%0A      head = head.next;%0A      return ret;%0A    %7D%0A%0A    public T min() %7B%0A      return min.val.val;%0A    %7D%0A  %7D%0A%0A  static class Node%3CT%3E %7B%0A    T val;%0A    Node next;%0A%0A    public Node(T val) %7B%0A      this.val = val;%0A    %7D%0A  %7D%0A%7D%0A

Problem 3_2 solution