Skip to content

Instantly share code, notes, and snippets.

@bshlgrs
Created August 14, 2015 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bshlgrs/c390c2c74b006fc09bac to your computer and use it in GitHub Desktop.
Save bshlgrs/c390c2c74b006fc09bac to your computer and use it in GitHub Desktop.
import scala.collection.mutable
class MinStack {
val myStack = mutable.Stack[Int]
def push(item: Int) = myStack.push(item)
def pop() = myStack.pop()
// BAD! Linear time
def getMin() = myStack.min
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment