✅ Simple Java Solution
CODE\nJava []\npublic int maxTwoEvents(int[][] events) {\n\tArrays.sort(events, (int a[], int b[])->{\n\t\tif(a[1] == b[1]){\n\t\t\treturn b[2]-a[2];\n\t\t}\n\t
## **CODE**\n```Java []\npublic int maxTwoEvents(int[][] events) {\n\tArrays.sort(events, (int a[], int b[])->{\n\t\tif(a[1] == b[1]){\n\t\t\treturn b[2]-a[2];\n\t\t}\n\t\treturn a[1]-b[1];\n\t});\n\tint max = 0;\n\tTreeMap<Integer,Integer> map = new TreeMap<>();\n\tmap.put(0,0);\n\tfor(int[] e:events){\n\t\tint earn = e[2];\n\t\tearn += map.get(map.floorKey(e[0]-1));\n\t\t// System.out.println(e[0]+" "+e[1]+" "+e[2]);\n\t\tif(map.get(map.floorKey(e[1])) < e[2]){\n\t\t\tmap.put(e[1], e[2]);\n\t\t}\n\t\t// System.out.println(map);\n\t\tmax = Math.max(earn, max);\n\t\t// System.out.println(max);\n\t}\n\treturn max;\n}\n```
['Java']