JAVA || Sorting || PriorityQueue || O(NlogN)
This problem can be solved with the help of Sorting and Heap - \n\nFirst sort all events by start time. If start time of two events are equal, sort them by end 
This problem can be solved with the help of Sorting and Heap - \n\nFirst sort all events by start time. If start time of two events are equal, sort them by end time.\nThen take a priority queue that takes an array containing [endtime, value]. Priority queue will sort elements on the basis of end time.\nIterate through events, for each event, calculate maximum value from all events that ends before current events start time and store this value in max variable.\n\n```\nclass Solution {\n    public int maxTwoEvents(int[][] events) \n    {\n        Arrays.sort(events , (a,b)-> a[0]!=b[0]?a[0]-b[0]:a[1]-b[1]);\n        PriorityQueue<int []> pq = new PriorityQueue<>((a,b)->a[0]-b[0]);\n        \n        int max = 0 , ans = 0;\n        pq.add(new int[]{events[0][1] , events[0][2]});\n        \n        for(int i=1 ; i<events.length ; i++)\n        {\n            while(!pq.isEmpty() && pq.peek()[0]<events[i][0])\n            {\n                int a[] = pq.poll();\n                max = Math.max(max , a[1]);\n            }\n            ans = Math.max(ans , max + events[i][2]);\n            pq.add(new int[]{events[i][1] , events[i][2]});\n        }\n        while(!pq.isEmpty())\n        {\n            ans = Math.max(ans , pq.poll()[1]);\n        }\n        \n        return ans;\n    }\n}\n```\n**Do Upvote if u like the solution!**
['Sorting', 'Heap (Priority Queue)', 'Java']