@Test public void testPush() { MaxStack maxStack = new MaxStack(); maxStack.push(1); maxStack.push(3); maxStack.push(2); Assert.assertEquals(3, maxStack.size()); }
public int push(int element) { if (maxStack.isEmpty()) { maxStack.add(element); } else { maxStack.add(0, Math.max(element, maxStack.peek().intValue())); } stack.add(0, element); return element; }
MaxStack { public int push(int element) { if (maxStack.isEmpty()) { maxStack.add(element); } else { maxStack.add(0, Math.max(element, maxStack.peek().intValue())); } stack.add(0, element); return element; } }
MaxStack { public int push(int element) { if (maxStack.isEmpty()) { maxStack.add(element); } else { maxStack.add(0, Math.max(element, maxStack.peek().intValue())); } stack.add(0, element); return element; }  }
MaxStack { public int push(int element) { if (maxStack.isEmpty()) { maxStack.add(element); } else { maxStack.add(0, Math.max(element, maxStack.peek().intValue())); } stack.add(0, element); return element; }  int push(int element); int pop(); int max(); int size(); }
MaxStack { public int push(int element) { if (maxStack.isEmpty()) { maxStack.add(element); } else { maxStack.add(0, Math.max(element, maxStack.peek().intValue())); } stack.add(0, element); return element; }  int push(int element); int pop(); int max(); int size();  }