sort and use priority queue
\n\nEvents (Sorted) ---> [Start, End, Value]\n\n            Time Axis -->\nEvent 1:   |------|\nEvent 2:       |-------|\nEvent 3:           |----|\n\nHeap --->
\n```\nEvents (Sorted) ---> [Start, End, Value]\n\n            Time Axis -->\nEvent 1:   |------|\nEvent 2:       |-------|\nEvent 3:           |----|\n\nHeap ---> Keeps Events Active\n    --------------\n    |  Event End |\n    |  Max Value |\n    --------------\n\nmax_so_far ---> Tracks maximum value from non-overlapping events.\n\nResult ---> max(max_so_far + Current Event Value)\n```\n\n```\ncomplexity - O(nlogn)\n```\n\n# Code\n```cpp []\nclass Solution {\n    struct cmp{\n        bool operator()(const vector<int> &a, const vector<int> &b){\n            return a[1] > b[1];\n        }\n    };\npublic:\n    int maxTwoEvents(vector<vector<int>>& events) {\n        ios_base::sync_with_stdio(false);\n\n        sort(events.begin(), events.end());\n        priority_queue<vector<int>, vector<vector<int>>, cmp> pQ;\n        int res = 0;\n        int max_so_far = 0;\n        for(const vector<int> &event: events){\n            while(!pQ.empty() && pQ.top()[1] < event[0]) { \n                max_so_far = max(max_so_far, pQ.top()[2]);\n                pQ.pop();\n            }\n            res = max(res, max_so_far + event[2]);\n            pQ.push(event);\n        }\n        return res;\n    }\n};\n\n```
['Two Pointers', 'Greedy', 'Sliding Window', 'Sorting', 'Heap (Priority Queue)', 'Merge Sort', 'C++']