C++ Sort by [Minimum - Actual]
The idea is to first do tasks with the largest difference between required and consumed energy.\n    \nThus, we sort the tasks, and then just track the energy r
The idea is to first do tasks with the largest difference between required and consumed energy.\n    \nThus, we sort the tasks, and then just track the energy requried.\n\n```cpp\nint minimumEffort(vector<vector<int>>& tasks) {\n    int energy = 0, res = 0;\n    sort(begin(tasks), end(tasks), [](vector<int> &t1, vector<int> &t2) \n         { return t1[1] - t1[0] > t2[1] - t2[0]; });\n    for (auto &t : tasks) {\n        res += max(0, t[1] - energy);\n        energy = max(energy, t[1]) - t[0];\n    }\n    return res;\n}\n```
[]