C++ version two heap solution of @dietpepsi
\nclass MedianFinder {\npublic:\n    \n    priority_queue<int> small;\n    priority_queue<int,vector<int>,greater<int>> large;\n    bool even;\n    MedianFinder
```\nclass MedianFinder {\npublic:\n    \n    priority_queue<int> small;\n    priority_queue<int,vector<int>,greater<int>> large;\n    bool even;\n    MedianFinder() {\n        even = true;\n    }\n    \n    void addNum(int num) {\n        if(even)\n        {\n            large.push(num);\n            small.push(large.top());\n            large.pop();\n        }\n        else\n        {\n            small.push(num);\n            large.push(small.top());\n            small.pop();\n        }\n        even=!even;\n    }\n    \n    double findMedian() {\n        if(even)\n            return (small.top()+large.top())/2.0;\n        else\n            return small.top();\n    }\n};\n```\n\nComment down for explanation if u have any query
['C', 'Heap (Priority Queue)', 'C++']