Designing a stack like data structure(push, pop) and a min() function which operates in constant time
Anonymous
One can use a stack, this gives you push()/ pop() operations. Modify it, instead of storing one value - store two. The other value is minimum under given element. Thus min() will just read the other value in constant time.
Check out your Company Bowl for anonymous work chats.