Java TreeMap solution
\nclass Solution {\n    public long maxTaxiEarnings(int n, int[][] rides) {\n        TreeMap<Integer,Long> maps = new TreeMap<Integer,Long>();\n        Arrays.s
```\nclass Solution {\n    public long maxTaxiEarnings(int n, int[][] rides) {\n        TreeMap<Integer,Long> maps = new TreeMap<Integer,Long>();\n        Arrays.sort(rides,(a,b) -> a[1] - b[1]);\n        maps.put(0,0L);\n        for(int i = 0; i < rides.length; i++){\n            Map.Entry<Integer,Long> e = maps.floorEntry(rides[i][0]);\n            long p = 0L;\n            if(maps.containsKey(rides[i][1]))\n                 p = maps.get(rides[i][1]);\n            long q = e.getValue() + (rides[i][1] - rides[i][0] + rides[i][2]);\n            if(q > p  && maps.lastEntry().getValue() < q){\n                 maps.put(rides[i][1],q);\n            }\n            maps.put(0,0L);\n        }\n        return maps.lastEntry().getValue();\n    }\n}\n```
['Tree', 'Java']