C++ || Sorting || Min Heap
define ll long long int\nclass Solution {\npublic:\n    \n    static bool sortByMe(vector &a,vector &b)\n    {\n        if(a[0] == b[0])\n        {\n           
#define ll long long int\nclass Solution {\npublic:\n    \n    static bool sortByMe(vector<int> &a,vector<int> &b)\n    {\n        if(a[0] == b[0])\n        {\n            return a[1] < b[1];\n        }\n        return a[0]<b[0];\n    }\n    long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {\n        \n        priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;\n        \n        ll ans = 0;\n        \n        sort(rides.begin(),rides.end(),sortByMe);\n        \n        n = rides.size();   \n        ll curr = 0;\n        \n        for(int i = 0;i<n;i++)\n        {\n            int st = rides[i][0];\n            int et = rides[i][1];\n            int tip = rides[i][2];\n            \n        \n            while(!pq.empty() && pq.top().first <= st)\n            {\n                if(curr < pq.top().second)\n                {\n                    curr = pq.top().second;\n                }\n                pq.pop();\n                \n            }\n            \n            ans = max(ans,et-st + tip + curr);\n            \n            pq.push({et,et-st + curr + tip});\n        }\n        \n        return ans;\n    }\n};
[]