C++ solutions
\nclass MedianFinder {\nprivate:\n    priority_queue<int> firstQ; // max_heap for the first half\n    priority_queue<int, std::vector<int>, std::greater<int> > 
```\nclass MedianFinder {\nprivate:\n    priority_queue<int> firstQ; // max_heap for the first half\n    priority_queue<int, std::vector<int>, std::greater<int> > secQ; // min_heap for the second half\npublic:\n    // Adds a number into the data structure.\n    void addNum(int num) {\n        if(firstQ.empty() || (firstQ.top()>num)) firstQ.push(num); // if it belongs to the smaller half\n        else secQ.push(num); \n        \n        // rebalance the two halfs to make sure the length difference is no larger than 1\n        if(firstQ.size() > (secQ.size()+1))\n        {\n            secQ.push(firstQ.top());\n            firstQ.pop();\n        }\n        else if(firstQ.size()+1<secQ.size())\n        {\n            firstQ.push(secQ.top());\n            secQ.pop();\n        }\n    }\n\n    // Returns the median of current data stream\n    double findMedian() {\n        if(firstQ.size() == secQ.size()) return firstQ.empty()?0:( (firstQ.top()+secQ.top())/2.0);\n        else return (firstQ.size() > secQ.size())? firstQ.top():secQ.top(); \n    }\n};\n```
['C', 'C++']