The below test case yields an unexpected output unlike the one produced on my laptop. I am curious on how the output was generated. Below is my code solution for the problem. Could anyone help me debug this test case?

Input: push(-1),top,getMin

Output: [-3,-1]

Expected: [-1,-1]

```
class MinStack:
# @param x, an integer
# @return an integer
top_elem = -1
min = float('inf')
stack = []
def push(self, x):
if x < self.min:
self.min = x
self.stack.append(x)
self.top_elem += 1
# @return nothing
def pop(self):
if self.top_elem == -1:
return
element = self.stack.pop()
self.top_elem -= 1
if element == self.min:
self.min = float('inf')
for item in self.stack:
if item < self.min:
self.min = item
return
# @return an integer
def top(self):
if self.top_elem != -1:
return self.stack[self.top_elem]
# @return an integer
def getMin(self):
if self.top_elem != -1
return self.min
```