Solution to 3.2, min stack