Stack which finds the minimum element
Nicely written. The space saving trick you did with min stack is especially nice.

When you push, the conditions can be a bit simpler:


push(data) {
  if (this.minStack.isEmpty() &amp;&amp; this.stack.isEmpty()) {
    this.minStack.push(data);
  } else if (data &lt;= this.minStack.peek()) {
    this.minStack.push(data);
  }
  this.stack.push(data);
}



The min stack will only be empty when the stack is empty, so you can drop the second condition in the first if statement. And since the else if branch does the same thing as the if branch, you can combine them:

push(data) {
  if (this.minStack.isEmpty() || data &lt;= this.minStack.peek()) {
    this.minStack.push(data);
  }
  this.stack.push(data);
}