Min Stack II

# last time, I build a min stack using perl6’s class.
# the problem is that the perl6 already have pop, push, min method.
# so, to solve the problem of name conflict, I have to rename the name.
# but there is another solution.
# use the multi instead of method.
# TIMTOWTDI

Advertisements

Min Stack

The problem: Min Stack
Design a data structure that provides push and pop operations, like a stack, plus a third operation that finds the minimum element. All three operations must perform in constant time. You may assume that all elements are distinct.

Use perl6’s class to implement

TODO: use multi……