✅ C++ || Two Approaches || using vector|| Min and Max Heap
Approach 1: (Using Vector) TLE\n\nclass MedianFinder {\npublic:\n    vector<double> arr;\n    MedianFinder() {\n        \n    }\n    \n    void addNum(int num) 
**Approach 1: (Using Vector) TLE**\n```\nclass MedianFinder {\npublic:\n    vector<double> arr;\n    MedianFinder() {\n        \n    }\n    \n    void addNum(int num) {\n        arr.push_back(num);\n    }\n    \n    double findMedian() {\n        sort(arr.begin(),arr.end());\n        int n = arr.size();\n        if(n%2 == 0){\n            double ans = (arr[(n/2)-1]+arr[n/2])/2;\n            return ans;\n        }\n        return arr[n/2];\n    }\n};\n\n```\n**Approach 2: (Max-Min Heap) \u2705**\n```\nclass MedianFinder {\npublic:\n    priority_queue<int> max_heap;\n    priority_queue<int,vector<int>,greater<int>> min_heap;\n    \n    MedianFinder() {\n        \n    }\n    \n    void addNum(int num) {\n        if(max_heap.size() > 0 && num > max_heap.top())\n        {\n            min_heap.push(num);\n        }\n        else\n        {\n            max_heap.push(num);\n        }\n        if(max_heap.size() > min_heap.size()+1)\n        {\n            min_heap.push(max_heap.top());\n            max_heap.pop();\n        }\n        if(min_heap.size() > max_heap.size()+1)\n        {\n            max_heap.push(min_heap.top());\n            min_heap.pop();\n        }\n    }\n    \n    double findMedian() {\n        if(max_heap.size() == min_heap.size())\n        {\n            return (max_heap.top()+min_heap.top())/2.0;\n        }\n        if(max_heap.size() > min_heap.size())\n        {\n            return max_heap.top();\n        }\n        else\n        {\n            return min_heap.top();\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```
['C', 'Heap (Priority Queue)']