Java TreeMap easy solution
\nclass Solution {\n    public long maxTaxiEarnings(int n, int[][] rides) {\n        Arrays.sort(rides, new Comparator<int[]>() {\n            public int compar
```\nclass Solution {\n    public long maxTaxiEarnings(int n, int[][] rides) {\n        Arrays.sort(rides, new Comparator<int[]>() {\n            public int compare(int[] ride1, int[] ride2) {\n                if (ride1[1] == ride2[1]) {\n                    return ride1[0] - ride2[0];\n                }\n                return ride1[1] - ride2[1];\n            }\n        });\n        TreeMap<Integer, Long> tm = new TreeMap<>();\n        tm.put(0, 0l);\n        for (int[] ride : rides) {\n            if (ride[1] > n) {\n                break;\n            }\n            long curr = tm.floorEntry(ride[0]).getValue() + ride[1] - ride[0] + ride[2];\n            if (curr > tm.lastEntry().getValue()) {\n                tm.put(ride[1], curr);\n            }\n        }\n        return tm.lastEntry().getValue();\n    }\n}\n```
['Tree', 'Java']