Thoroughly explaining what's going on, a very concise solution accepted as best submission in C
Before we really get started, let\'s first make some points clear about this problem and also there are some complaints about the specification of the problem -
Before we really get started, let\'s first make some points clear about this problem and also there are some complaints about the specification of the problem -> so misleading!    Here is the detailed specification of the problem: \n\n- push will push the value to the stack - add a new top value;\n- pop will delete the top value of the stack - the only removing operation;\n- top will just return he top value of the stack - no removing;\n- getMin will just get the minimal value among the values in stack - no removing;\n\nThe true question comes around now, how can we just get the minimal of the stack in constant time? First we need to think about this -> it\'s a stack -> values comes and goes at the rear of an array -> so we can just use another array <font color="#0000ff">mins</font> to store the so-far minimals which exactly means that when we are pushing values to the stack from the very beginning, we need to check whether the so-far minimal will be changed, if it\'s changed for the incoming new value, we need to push this value to the <font color="#0000ff">mins</font> array and so on and so on.\n\n> the other array <font color="#0000ff">mins</font> will store the so-far minimals and should be updated in each push and pop operation to maintain this feature\n\n- so-far minimals means the minimals among values from the bottom till the top of the stack\n\nBang! End of Story!\n\nAnother typical example using space to reduce time cost:\n\n- space cost O(n)\n- time cost O(1)\n\n----------\n\n\n    typedef struct\n    {\n        int *arr;\n        int count;\n        int *mins;\n        int minCount;\n    } MinStack;\n    \n    void minStackCreate(MinStack *stack, int maxSize)\n    {\n        stack->arr = (int*)malloc(sizeof(int)*maxSize);\n        stack->mins = (int*)malloc(sizeof(int)*maxSize); //record the mins till the top of the arr;\n        stack->count = 0;\n        stack->minCount = 0;\n    }\n    \n    void minStackPush(MinStack *stack, int element) //push it to arr normally, but meantime check whether we should push it to mins;\n    {\n        stack->arr[stack->count++] = element;\n        if(stack->minCount==0 || element<=stack->mins[stack->minCount-1])\n            stack->mins[stack->minCount++] = element;\n    }\n    \n    void minStackPop(MinStack *stack) //pop will always pop the top -> the top of mins and arr;\n    {\n        int top = stack->arr[stack->count-1];\n        if(stack->mins[stack->minCount-1] == top)\n            stack->minCount--;\n        stack->count--;\n    }\n    \n    int minStackTop(MinStack *stack) //just return the top, needless to remove it;\n    {\n        return stack->arr[stack->count-1];\n    }\n    \n    int minStackGetMin(MinStack *stack) //just return the min, needless to remove it;\n    {\n        return stack->mins[stack->minCount-1];\n    }\n    \n    void minStackDestroy(MinStack *stack)\n    {\n        free(stack->arr);\n        free(stack->mins);\n    }
[]