classMinStack(object):def__init__(self):# stack with entries of (value, cur_min)self.l=[]defpush(self,x):""" :type x: int :rtype: nothing """prev_min=self.getMin()ifprev_min==Noneorprev_min>x:cur_min=xelse:cur_min=prev_minself.l.append((x,cur_min))defpop(self):""" :rtype: nothing """ifself.l:self.l.pop()deftop(self):""" :rtype: int """ifnotself.l:returnNonereturnself.l[-1][0]defgetMin(self):""" :rtype: int """ifnotself.l:returnNonereturnself.l[-1][1]