```
def __init__(self):
"""
initialize your data structure here.
"""
self.stack = []
self.minheap = []
def push(self, x):
"""
:type x: int
:rtype: void
"""
self.stack.append(x)
heapq.heappush(self.minheap, x)
def pop(self):
"""
:rtype: void
"""
if self.stack:
val = self.stack.pop()
if self.minheap:
self.minheap.remove(val)
heapq.heapify(self.minheap)
def top(self):
"""
:rtype: int
"""
if self.stack:
return self.stack[-1]
def getMin(self):
"""
:rtype: int
"""
return self.minheap[0]
```