C# Binary Search + Max Value caching
\npublic class Solution {\n    public int MaxTwoEvents(int[][] events) {\n        Array.Sort(events, (x,y) => x[0].CompareTo(y[0]));\n        int[] cache = new 
```\npublic class Solution {\n    public int MaxTwoEvents(int[][] events) {\n        Array.Sort(events, (x,y) => x[0].CompareTo(y[0]));\n        int[] cache = new int[events.Length];\n        cache[cache.Length-1] = events[events.Length-1][2];\n        for(int i = events.Length-2; i >= 0; i--) {\n               cache[i] = Math.Max(events[i][2], cache[i+1]); \n\t    }\n        int res = 0;\n        foreach(int[] ev in events)\n        {\n            int val = ev[2];\n            int i = search(ev[1], events);\n            if(i != -1) val += cache[i];\n            res = Math.Max(res, val);\n        }\n        return res;\n    }\n    \n    private int search(int target, int[][] events)\n    {\n        int lo = 0, hi = events.Length-1;\n        while(lo < hi)\n        {\n            int mid = lo + (hi-lo)/2;\n            if(events[mid][0] > target)\n                hi = mid;\n            else\n                lo = mid+1;\n        }        \n        return events[lo][0] > target ? lo : -1;\n    }    \n}\n```
['Binary Tree']