✅ C++ | PRIORITY QUEUE (2 HEAPS) | O(LOG N) - ADD , O(1) - MEDIAN | EASY & CLEAN CODE
\n    priority_queue<int> q1;\n    priority_queue<int,vector<int>,greater<int>> q2;\n    \n    void balance()\n    {\n        while(q1.size()<q2.size())\n      
```\n    priority_queue<int> q1;\n    priority_queue<int,vector<int>,greater<int>> q2;\n    \n    void balance()\n    {\n        while(q1.size()<q2.size())\n        {\n            q1.push(q2.top());\n            q2.pop();\n        }\n        \n        if(q1.size()-q2.size()>1)\n        {\n            q2.push(q1.top());\n            q1.pop();\n        }\n    }\n    \n    MedianFinder() {\n        \n    }\n    \n    void addNum(int num) {\n        \n        if(q1.empty() || num<q1.top())\n            q1.push(num);\n        else\n            q2.push(num);\n        \n        balance();\n    }\n    \n    double findMedian() {\n        if(q1.size()>q2.size())\n            return q1.top();\n        else\n            return ((float)q1.top()+q2.top())/2;\n    }\n```\n\n**Do share your suggestions & upvote if you like !!!**  \uD83D\uDE04
['C', 'Heap (Priority Queue)', 'C++']