79175315

Date: 2024-11-10 16:56:55
Score: 1
Natty:
Report link

The testCase attempts to push the following : 0, 1, 0.

You only push a new value on the stack, if the current value at the top of the stack is > the value you are trying to push. So your min stack will take 0, skip 1 and again skip 0.

After 3 pushes: stack = [0, 1, 0], minStack = [0]

getMin = minStack.peek = 0

Then you do a pop. So stack = [0, 1], minStack = []

Now getMin = minStack.peek() = not possible because stack is empty.

Your code doesn't account for what happens when there are multiple instances of the same min.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: brenDon_Xavi