Python | O(nlogn) solution | sort, binary search
\nclass Solution:\n    def maxTwoEvents(self, events: List[List[int]]) -> int:\n        events.sort()\n        N = len(events)\n\n        start, end, vals = [],
```\nclass Solution:\n    def maxTwoEvents(self, events: List[List[int]]) -> int:\n        events.sort()\n        N = len(events)\n\n        start, end, vals = [], [], []\n        for s,e,v in events:\n            start.append(s)\n            end.append(e)\n            vals.append(v)\n        \n        max_at_index = {}\n        curr = float("-inf")\n        for i in range(N-1,-1,-1):\n            curr = max(vals[i], curr)\n            max_at_index[i] = curr\n        \n        ans = float(\'-inf\')\n        for i,s in enumerate(start):\n            second = bisect.bisect(start, end[i])\n            if second < N:\n                ans = max(ans, vals[i] + max_at_index[second])\n            else:\n                ans = max(ans,vals[i])\n        return ans\n```
['Sorting', 'Binary Tree', 'Python']