问题
样例
代码
typedef struct {
int top;
int data[110];
} MinStack;
/** initialize your data structure here. */
MinStack* minStackCreate(int maxSize) {
MinStack*p=malloc(sizeof(MinStack));
p->top=-1;
return p;
}
void minStackPush(MinStack* obj, int x) {
obj->top++;
obj->data[obj->top]=x;
}
void minStackPop(MinStack* obj) {
if(obj->top==-1)
return;
obj->top--;
}
int minStackTop(MinStack* obj) {
return obj->data[obj->top];
}
int minStackGetMin(MinStack* obj) {
int temp=0x7fffffff;
for(int i=0;i<=obj->top;i++)
{if(obj->data[i]<temp)
temp=obj->data[i];}
return temp;
}
void minStackFree(MinStack* obj) {
free(obj);
}