✔️✔️[C++] Explained using Priority queue Simple solution
\nstruct Compare {\n    bool operator()(pair<int,int> &a, pair<int,int> &b){\n        return a.first-a.second < b.first-b.second;\n    }\n};\n\nclass Solution {
```\nstruct Compare {\n    bool operator()(pair<int,int> &a, pair<int,int> &b){\n        return a.first-a.second < b.first-b.second;\n    }\n};\n\nclass Solution {\npublic:\n    int minimumEffort(vector<vector<int>>& tasks) {\n        priority_queue<pair<int,int>, vector<pair<int,int>>, Compare> pq;\n        // sorted for max abs difference of [minimum, actual]\n        for(auto v:tasks) pq.push({v[1], v[0]});\n        int res = 0, curr = 0; // curr min energy\n\n        while(!pq.empty()){\n            if(pq.top().first > curr) // minimum energy reqd > curr energy\n                res += (pq.top().first-curr), // res += difference to add\n                curr = pq.top().first; // curr energy set\n                \n            curr -= pq.top().second; // using the actual from curr energy\n\n            pq.pop();\n        }\n        return res;\n    }\n};\n```
['Greedy', 'Heap (Priority Queue)', 'C++']