typedef struct { int top; int minIndex[10000]; int stack[10000]; } MinStack; MinStack* minStackCreate() { MinStack* obj = (MinStack*)calloc(1,sizeof(MinStack)); obj->top=-1; return obj; } void minStackPush(MinStack* obj, int x) { obj->stack[++obj->top] = x; if (obj->top >= 1 && x >= obj->minIndex[obj->top-1]) obj->minIndex[obj->top] =obj->minIndex[obj->top-1]; else obj->minIndex[obj->top] = x; } void minStackPop(MinStack* obj) { obj->top--; } int minStackTop(MinStack* obj) { return obj->stack[obj->top]; } int minStackGetMin(MinStack* obj) { return obj->minIndex[obj->top]; } void minStackFree(MinStack* obj) { free(obj); }