C++ || Min Heap
\nclass Solution {\npublic:\n    \n    int maxTwoEvents(vector<vector<int>>& events) {\n        int n = events.size();\n        priority_queue<pair<int,int>,vec
```\nclass Solution {\npublic:\n    \n    int maxTwoEvents(vector<vector<int>>& events) {\n        int n = events.size();\n        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;\n        // priority queue minheap --> to store endtime and values of the events\n        sort(events.begin(),events.end()); // sort according to start time\n        \n        int result = 0;\n        int maxval = 0; // maxvalue stores the maximum value of the values encountered so far and \n        // whose ending time is less than the start time of the current event\n        for(int i=0; i<n; i++)\n        {\n            while(!pq.empty() && pq.top().first < events[i][0])\n            {\n                maxval = max(maxval,pq.top().second);\n                pq.pop();\n            }\n            result = max(result, maxval + events[i][2]);\n            pq.push({events[i][1],events[i][2]});\n        }\n        return result;\n        \n    }\n};\n```
[]