public void Push(int x) { if (head == null) { head = new NodeWithMin(x, x, null); } else { head = new NodeWithMin(x, Math.Min(x, head.min), head); } }
public NodeWithMin(int val, int min, NodeWithMin next) { this.val = val; this.min = min; this.next = next; }
public void Pop() { head = head.next; }