Explained C++ Min-heap Solution
Sort all the intervals in the events vector based on start time. The reason to sort this using start time will help when we check whether my current interval is
1. Sort all the intervals in the events vector based on start time. The reason to sort this using start time will help when we check whether my current interval is non-overlapping with the interval at the top of min-heap(priority queue).\n\n2. You have to maintain a `min-heap`  which will make sure you can have the interval with least ending time at the top/front so that you will have better chances that your current interval can get a match.\n3. If the current interval\'s start time > end time of interval at top of priority queue, you get a match as they would be non-overlapping. So you maintain  a `Max` of the value of intervals from the min-heap. And after getting the ultimate match for every current interval, you maintain a `ans` and update it with `Max + curVal`.\n4. At the end, you push the current interval in the min-heap for that will be checked for pairing for further intervals.\n\n\n```\nclass Solution {\npublic:\n    int maxTwoEvents(vector<vector<int>>& events) {\n        \n        sort(events.begin(),events.end());\n        \n        priority_queue<tuple<int,int,int>> pq;\n        int Max = 0, ans = 0;\n        for(int i=0;i<events.size();i++) {\n        \n            while(!pq.empty()) {\n                \n                auto top = pq.top();\n                if(events[i][0] > -get<0>(top)) {\n                    Max = max(Max,get<2>(top));\n                    pq.pop();\n                    continue;\n                }\n                break;\n            }\n            \n            ans = max(ans, Max + events[i][2]);\n            pq.push(make_tuple(-1*events[i][1],events[i][0],events[i][2]));\n        }\n        \n        return ans;\n    }\n};\n```
['Sorting', 'Heap (Priority Queue)']