(value int64)
| 25 | } |
| 26 | |
| 27 | func (s *Stack) Push(value int64) { |
| 28 | s.top = &Element{value, s.top} |
| 29 | s.size++ |
| 30 | if len(s.min) == 0 { |
| 31 | s.min = append(s.min, value) |
| 32 | } else if s.min[len(s.min)-1] > value { // if last elem in slice is greater |
| 33 | s.min = append(s.min, value) // add the value to the end of the slice |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // Remove the top element from the stack and return it's value |
| 38 | // If the stack is empty, return maxInt, error |