PuTtA EaSY Solution C++ ✅ | Beats 85% 🔥🔥
\n# Code\n\nclass MedianFinder {\npublic:\n        priority_queue<double> maxheap;\n        priority_queue<double,vector<double> ,greater<double>> minheap;\n   
\n# Code\n```\nclass MedianFinder {\npublic:\n        priority_queue<double> maxheap;\n        priority_queue<double,vector<double> ,greater<double>> minheap;\n    MedianFinder() {\n\n    }\n    \n    void addNum(int num) {\n        maxheap.push(num);\n        if(!maxheap.empty() && !minheap.empty() && maxheap.top() > minheap.top()){\n            double temp = maxheap.top();\n            maxheap.pop();\n            minheap.push(temp);\n        }\n       if( maxheap.size() > minheap.size() + 1){\n            double temp = maxheap.top();\n            maxheap.pop();\n            minheap.push(temp);\n        }\n\n        if( minheap.size() > maxheap.size()+1){\n            double temp = minheap.top();\n            minheap.pop();\n            maxheap.push(temp);\n        }\n    } \n    \n    double findMedian() {\n        if( maxheap.size() > minheap.size()) return maxheap.top();\n        if( minheap.size() > maxheap.size()) return minheap.top();\n        return (maxheap.top() + minheap.top())/2;\n\n    }\n};\n\n/**\n * Your MedianFinder object will be instantiated and called as such:\n * MedianFinder* obj = new MedianFinder();\n * obj->addNum(num);\n * double param_2 = obj->findMedian();\n */\n```
['Two Pointers', 'Design', 'Sorting', 'Heap (Priority Queue)', 'Data Stream', 'C++']