Interview Question

Mobile Software Engineer Interview San Francisco, CA

Design a stack implementation that has "push", "pop" and

  ook at the top-most value of the stack without popping it off the stack), and then design a function that tells the caller what the "minimum" value in the stack will be.
Tags:
analytical
Answer

Interview Answer

1 Answer

0

Turns out this is a trickier problem than it looks. Sure, it's easy to design a stack that does push, pop and peek, but the "minimum" function needs to keep track of the minimum values of the stack in order (i.e. if a "1" gets popped off the stack, "minimum" must then return the next minimum even if it's deep down within the stack). In my case, I would have come up with a linked list of minimums.

Interview Candidate on Jan 29, 2013

Add Answers or Comments

To comment on this question, Sign In with Facebook or Sign Up