It seems there's no C solution. Share mine. 84 ms
I use max heap and min heap, O(logn) for addNum, O(1) for getMedium.\n\n\n    #include \n    #include \n    \n    struct MedianFinder {\n        int maxHeap; / 
I use max heap and min heap, O(logn) for addNum, O(1) for getMedium.\n\n\n    #include <stdio.h>\n    #include <stdlib.h>\n    \n    struct MedianFinder {\n        int *maxHeap; /* store the smaller half */\n        int *minHeap; /* store the larger half */\n        int maxHeapCapacity;\n        int minHeapCapacity;\n        int maxHeapSize;\n        int minHeapSize;\n        double median;\n    };\n    \n    void swap(int *a, int *b) {\n        int c = *a;\n        *a = *b;\n        *b = c;\n    }\n    \n    void addHeap(int **heap, int *size, int *capacity, int data) {\n        if (*size == *capacity) {\n            int newCapacity = (*capacity) * 2; /* resize */\n            int *newHeap = (int *)malloc(newCapacity * sizeof(int));\n            for (int i = 0; i < *capacity; i++) {\n                newHeap[i] = (*heap)[i];\n            }\n            if (*heap)\n                free(*heap);\n            *heap = newHeap;\n            *capacity = newCapacity;\n        }\n        (*heap)[*size] = data;\n        (*size)++;\n    }\n    \n    void siftUpMax(int *heap, int size) {\n        int parent, child;\n        child = size - 1;\n        while (child > 0) {\n            parent = (child - 1) / 2;\n            if (heap[parent] < heap[child])\n                swap(&heap[parent], &heap[child]);\n            child = parent;\n        }\n    }\n    \n    void siftDownMax(int *heap, int size) {\n        int parent, child;\n        parent = 0; child = 1;\n        while (child < size) {\n            if (child + 1 < size && heap[child] < heap[child + 1])\n                child = child + 1;\n    \n            if (heap[parent] >= heap[child]) break;\n            swap(&heap[parent], &heap[child]);\n            parent = child;\n            child = parent * 2 + 1;\n        }\n    }\n    \n    void siftUpMin(int *heap, int size) {\n        int parent, child;\n        child = size - 1;\n        while (child > 0) {\n            parent = (child - 1) / 2;\n            if (heap[parent] > heap[child])\n                swap(&heap[parent], &heap[child]);\n            child = parent;\n        }\n    }\n    \n    void siftDownMin(int *heap, int size) {\n        int parent, child;\n        parent = 0; child = 1;\n        while (child < size) {\n            if (child + 1 < size && heap[child] > heap[child + 1])\n                child = child + 1;\n    \n            if (heap[parent] <= heap[child]) break;\n            swap(&heap[parent], &heap[child]);\n            parent = child;\n            child = parent * 2 + 1;\n        }\n    }\n    \n    /** Initialize your data structure here. */\n    struct MedianFinder* MedianFinderCreate() {\n        struct MedianFinder *mf = (struct MedianFinder *)malloc(sizeof(struct MedianFinder));\n        mf->maxHeap = (int *)malloc(sizeof(int));\n        mf->minHeap = (int *)malloc(sizeof(int));\n        mf->maxHeap[0] = mf->minHeap[0] = 0;\n        mf->minHeapSize = mf->maxHeapSize = 0;\n        mf->minHeapCapacity = mf->maxHeapCapacity = 1;\n        mf->median = 0;\n        return mf;\n    }\n    \n    /** Inserts a num into the data structure. */\n    void addNum(struct MedianFinder* mf, int num) {\n        if (mf == NULL) return;\n    \n        if (mf->maxHeapSize == mf->minHeapSize) {\n            if (num > mf->median) {\n                addHeap(&mf->minHeap, &mf->minHeapSize, &mf->minHeapCapacity, num);\n                siftUpMin(mf->minHeap, mf->minHeapSize);\n                mf->median = mf->minHeap[0];\n            }\n            else {\n                addHeap(&mf->maxHeap, &mf->maxHeapSize, &mf->maxHeapCapacity, num);\n                siftUpMax(mf->maxHeap, mf->maxHeapSize);\n                mf->median = mf->maxHeap[0];\n            }\n        }\n        else {\n            if (num > mf->minHeap[0]) {\n                addHeap(&mf->minHeap, &mf->minHeapSize, &mf->minHeapCapacity, num);\n                siftUpMin(mf->minHeap, mf->minHeapSize);\n                if (mf->minHeapSize >= mf->maxHeapSize + 2) {\n                    addHeap(&mf->maxHeap, &mf->maxHeapSize, &mf->maxHeapCapacity, mf->minHeap[0]);\n                    siftUpMax(mf->maxHeap, mf->maxHeapSize);\n                    swap(&mf->minHeap[0], &mf->minHeap[mf->minHeapSize - 1]);\n                    mf->minHeapSize--;\n                    siftDownMin(mf->minHeap, mf->minHeapSize);\n                }\n            }\n            else {\n                addHeap(&mf->maxHeap, &mf->maxHeapSize, &mf->maxHeapCapacity, num);\n                siftUpMax(mf->maxHeap, mf->maxHeapSize);\n                if (mf->maxHeapSize >= mf->minHeapSize + 2) {\n                    addHeap(&mf->minHeap, &mf->minHeapSize, &mf->minHeapCapacity, mf->maxHeap[0]);\n                    siftUpMin(mf->minHeap, mf->minHeapSize);\n                    swap(&mf->maxHeap[0], &mf->maxHeap[mf->maxHeapSize - 1]);\n                    mf->maxHeapSize--;\n                    siftDownMax(mf->maxHeap, mf->maxHeapSize);\n                }\n            }\n            mf->median = mf->maxHeap[0] + (mf->minHeap[0] - mf->maxHeap[0]) / 2.0;\n        }\n    }\n    \n    /** find the median of current data stream */\n    double findMedian(struct MedianFinder* mf) {\n        if (mf == NULL) return 0;\n        return mf->median;\n    }\n    \n    /** Deallocates memory previously allocated for the data structure. */\n    void MedianFinderFree(struct MedianFinder* mf) {\n        if (mf == NULL) return;\n        if (mf->maxHeap) free(mf->maxHeap);\n        if (mf->minHeap) free(mf->minHeap);\n        free(mf);\n    }\n    \n    // Your MedianFinder object will be instantiated and called as such:\n    // struct MedianFinder* mf = MedianFinderCreate();\n    // addNum(mf, 1.0);\n    // findMedian(mf);\n    // MedianFinderFree(mf);\n    \n    int main() {\n        struct MedianFinder* mf = MedianFinderCreate();\n    \n        addNum(mf, 1);\n        printf("%lf\\n", findMedian(mf));\n        addNum(mf, 2);\n        printf("%lf\\n", findMedian(mf));\n        addNum(mf, 3);\n        printf("%lf\\n", findMedian(mf));\n        addNum(mf, 4);\n        printf("%lf\\n", findMedian(mf));\n        addNum(mf, 5);\n        printf("%lf\\n", findMedian(mf));\n        addNum(mf, 6);\n        printf("%lf\\n", findMedian(mf));\n        addNum(mf, 7);\n        printf("%lf\\n", findMedian(mf));\n        addNum(mf, 8);\n        printf("%lf\\n", findMedian(mf));\n        addNum(mf, 9);\n        printf("%lf\\n", findMedian(mf));\n        addNum(mf, 10);\n        printf("%lf\\n", findMedian(mf));\n    \n        MedianFinderFree(mf);\n    \n        return 0;\n    }
[]